I want to import a CSV file to my Mysql table using Load data infile: here's my current code :
LOAD DATA INFILE '../myfile.csv'
INTO TABLE data
FIELDS
TERMINATED BY ','
ENCLOSED BY '"'
ESCAPED BY '"'
LINES TERMINATED BY '\n' IGNORE 1 LINES (@f1,@f2...) set `f1`=@f1,...,fk=13 ;
This is the first part of the csv file :
Timestamp,FromName,FromID,FromA,FromAID,FromURL,ToCName,ToCID,ToCTarget,ToAName,ToAID,ToAURL,UUID,Model,OS,Country,Type,Value
"2012-10-29 07:02:20","NH","4f7898654fgh02","Halloween Game","589754hj67d00021","78643609","","","","Game 1™","4f754hj67d00014","58975449","988675ffgh555f3284530","iPhone","5.1.1","GB","cpi","0.5"
this gives me a 0 rows inserted, but if i replace IGNORE 1 LINES with IGNORE 0 LINES the file is imported successfully (of course without ignoring the first line).
Any help is appreciated.
Removing this line solved the problem :
ESCAPED BY '"'
working code :
LOAD DATA INFILE '../myfile.csv'
INTO TABLE data
FIELDS
TERMINATED BY ','
ENCLOSED BY '\"'
LINES TERMINATED BY '\n' IGNORE 1 LINES (@f1,@f2...) set `f1`=@f1,...,fk=13 ;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With