I am using the following statement in order to insert data from file.
load data infile 'filename.csv'
ignore
into table tbl (clo);
I need to ignore the blank lines in the file. How can I do this.
You cannot skip lines unless they are at the beginning of the file which you can use the IGNORE N LINES
option.
Use sed before importing:
sed -i '/^\s*$/d' filename.csv
For more details: Delete empty lines using SED
LOAD DATA INFILE 'filename.csv'
INTO TABLE your_table
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
ESCAPED BY '\\'
LINES TERMINATED BY '\r\n';
The \r is necessary on Windows files, if you're running this on *nix you shouldn't need them.