How do I import a csv-file into a table via Drupal? I would like to import a csv into a table via Drupal. I use Drupal 7.

I create a content type 'Import', which contains a File field to upload a file to the server (destination: sites / default / files / import / *)

When I validate my form content 'Import', I will wish to make a db_query ()

db_query ("
LOAD DATA INFILE '$ csv_filename' INTO TABLE $ temp_table
FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '\"'
LINES TERMINATED BY '\\n'
IGNORE 1 LINES ");


$ csv_filename, I test the relative and absolute way, but drupal tells me it can not find the file. I even give the rights to the file to test 777 but it is not ca.

$ temp_table is my table, it already exists in the database.

You would know the procedure and a use case that works for this query?
I don't know if this quite what you're looking for, but the Feeds module can import CSV content into nodes. Perhaps it could help...

Import or aggregate data as nodes, users, taxonomy terms or simple database records.

One-off imports and periodic aggregation of content
Import or aggregate RSS/Atom feeds
Import or aggregate CSV files
Import or aggregate OPML files
PubSubHubbub support
Create nodes, users, taxonomy terms or simple database records from
import
Extensible to import any other kind of content
Granular mapping of input elements to Drupal content elements
Exportable configurations
Batched import for large files