0

I'm attempting to load a .txt file into the existing invoice table. When trying LOAD DATA INFILE, MYSQL goes through all of the rows in my .txt file then throws this error message.

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

It's obviously going through every row of data then gets to the next row and reads it as part of the dataset. Is there a way to limit the rows read or an END statement I am missing? This file was a .csv but I found out the dataset was littered with random commas in strings.

LOAD DATA  INFILE 'C:/ProgramData/MySQL/MySQL Server 8.0/Uploads/e_commerce_data.txt'
INTO TABLE invoice
CHARACTER SET latin1
fields terminated by '  '
lines terminated by '\r'
ignore 1 lines;
  • your configuration looks not right how sure are you about \r check th eline endings with an hex editor – nbk Sep 14 '21 at 19:25
  • If strings in your CSV file are quoted then you can use `ENCLOSED BY '"'`. That will prevent comma problem. See https://stackoverflow.com/questions/11759199/load-data-infile-dealing-with-fields-with-comma – endo64 Sep 14 '21 at 19:47
  • @nbk `lines terminated by '\r\n'` worked for me. thanks for the comment. – Derek Frank Sep 14 '21 at 20:57

0 Answers0