开发者

LOAD DATA LOCAL, How do I skip the first line?

开发者 https://www.devze.com 2022-12-09 14:28 出处:网络
I\'m trying to Load a CSV file into my MySQL database, But I would like to skip the first line. I fact It contains the name of my columns and no interesting data.

I'm trying to Load a CSV file into my MySQL database, But I would like to skip the first line.

I fact It contains the name of my columns and no interesting data.

Here is t开发者_开发技巧he query I'm using:

LOAD DATA LOCAL INFILE '/myfile.csv' 
INTO TABLE tableName
FIELDS TERMINATED BY ','
ENCLOSED BY '\"' 
LINES TERMINATED BY '\n' 
(column,column,column);


LOAD DATA INFILE '/tmp/test.txt' INTO TABLE test IGNORE 1 LINES;

(reference)


For those curious, IGNORE N LINES should be after the separator qualifiers:

LOAD DATA LOCAL INFILE '/myfile.csv' 
INTO TABLE tableName
FIELDS TERMINATED BY ','
ENCLOSED BY '\"' 
LINES TERMINATED BY '\n' 
IGNORE 1 LINES
(column,column,column);


Try this:

IGNORE N LINES
LOAD DATA INFILE "/path/to/file.csv"
INTO TABLE MYTABLE 
COLUMNS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 LINES;
0

精彩评论

暂无评论...
验证码 换一张
取 消