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

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

Posted by: admin November 1, 2017 Leave a comment

Questions:

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 the 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);
Answers:
LOAD DATA INFILE '/tmp/test.txt' INTO TABLE test IGNORE 1 LINES;

(reference)

Questions:
Answers:

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);