mysql Row does not contain data for all columns

ehxuflar  于 2022-12-22  发布在  Mysql
关注(0)|答案(5)|浏览(384)

Im trying to import a text file containing:
http://pastebin.com/qhzrq3M7
Into my database using the command

Load data local infile 'C:/Users/Gary/Desktop/XML/jobs.txt' 
INTO Table jobs 
fields terminated by '\t';

But I keep getting the error Row 1-13 doesn't contain data for all columns

ibrsph3r

ibrsph3r1#

Make sure the last field of each row ends with \t. Alternatively, use LINES TERMINATED BY

LOAD DATA LOCAL INFILE 'C:/Users/Gary/Desktop/XML/jobs.txt' INTO TABLE jobs COLUMNS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\r';

\r is a carriage return character, similar to the newline character (i.e. \n )

bvn4nwqk

bvn4nwqk2#

I faced same issue. How i fixed the issue:

  1. Try to open the CSV file using Notepad++ (text editor)
  2. I've seen a blank line at the end of my file, I've deleted it.
    -- Hurrah, it resolved my issue.
    Below URL also can help you out to resolve the issue. http://www.thoughtspot.com/blog/5-magic-fixes-most-common-csv-file-problems
pxyaymoc

pxyaymoc3#

If you're on Windows, make sure to use the LINES TERMINATED BY \r\n as explained by the mariadb docs

eoigrqb6

eoigrqb64#

sounds like load data local infile expects to see a value for each column.
You can edit the file by hand (to delete those rows -- could be blank lines), or you can create a temp table, insert the rows into a single column, and write a mysql command to split the rows on tab and insert the values into the target table

63lcw9qa

63lcw9qa5#

Make sure there are no ""s at the end of any field. In the csv viewed as text this would look like "," which is obviously a no-no, since that comma will be ignored so you won't have enough columns.
(This primarily applies when you don't have field encasings like quotes around each field.)

相关问题