0

I created a table(tbldemo) with 22 columns using a "create table" statement in mysql, when trying to insert the data from a .csv file using "Load data infile" statement it's giving me the error, Now how do I ignore the rows whose entire row is null or empty

 Error Code: 1261. Row 11513 doesn't contain data for all columns

this is what I used to load the data from .csv

LOAD DATA INFILE 'D:/Singapore/rau_sales_order.csv' INTO TABLE tbldemo
 FIELDS TERMINATED BY ',' 
ENCLOSED BY '"'  LINES TERMINATED BY '\r\n'
 IGNORE 1 LINES;

I don't want to open .csv file and clean the data from the file by filtering it for null, instead want to do it directly by query.Is there any way to acheive this?. Thanks in advance.

Deepesh
  • 820
  • 1
  • 14
  • 32

1 Answers1

0

You need some preprocessing of file. For example, remove blank lines. This will help if problem is caused by empty lines.

sed -i '/^[[:space:]]*$/d' file.csv
Community
  • 1
  • 1
Andrew
  • 1,858
  • 13
  • 15