我想使用 Load data infile 将 CSV 文件导入我的 Mysql 表:这是我当前的代码:
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 ;
这是 csv 文件的第一部分:
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"
这给了我插入的 0 行,但是如果我将 IGNORE 1 LINES 替换为 IGNORE 0 LINES,则文件将成功导入(当然不会忽略第一行)。
任何帮助表示赞赏。