-2

I am uploading huge csv file in a mysql database using LOAD DATA local INFILE command.

The table has got single field(hids) only which is integer,primary and autoincrement.The query is

$insert_query = "LOAD DATA local INFILE '".$target_path."' INTO table master_huts(hids) OPTIONALLY ENCLOSED BY  '\"'   IGNORE 1 LINES  ";

The csv file contains,

ID
"343"
"454"
"777"

If I remove the double quotes from csv file then it works fine. How can I tell MySql to ignore double quotes from csv file.

user3671491
  • 99
  • 1
  • 10
  • You're missing the keyword `FIELDS` as in `FIELDS OPTIONALLY ENCLOSED...`. It's not clear from the syntax that you can omit it if you're using one of the associated clauses. –  Jun 23 '14 at 23:11
  • You asked a question 7 hours ago... and the answer I gave 7 hours ago was to include **`FIELDS OPTIONALLY ENCLOSED BY`** before the `IGNORE`. And you've omitted the keyword **`FIELDS`** which was included in my answer. [http://dev.mysql.com/doc/refman/5.1/en/load-data.html](http://dev.mysql.com/doc/refman/5.1/en/load-data.html) – spencer7593 Jun 23 '14 at 23:39
  • possible duplicate of [Parse error for load data infile in mysql & php](http://stackoverflow.com/questions/24373129/parse-error-for-load-data-infile-in-mysql-php) –  Jun 24 '14 at 04:23
  • Sorry @spencer7593 I didn't get any email or notification from stackoverflow yesterday night.So I had to post a question with the very latest updates I had at that point of time.Probably there was a maintenance work going on and I missed the red notification in the header. I am going back to my first post. Sorry guys once again. – user3671491 Jun 24 '14 at 13:12

1 Answers1

0

Try this:

$insert_query = "LOAD DATA local INFILE '".$target_path."' INTO table master_huts(hids) FIELDS ENCLOSED BY '”' LINES TERMINATED BY '\n' IGNORE 1 LINES;