Invalid field count in CSV input on line XX in phpmyadmin?

1

  1. I have a 16MB CSV file with 50,000 lines that I want to import into my database.
  2. I go to the PHPMyAdmin-Interface, choose IMPORT and set the correct options.
  3. The import fails with the error Invalid field count in CSV input on line 24,333.
  4. When I look into the CSV file via Notepad++ and turn on the Option View -> Show Symbols -> Show all Characters everything in this line looks absolutely okay, means like exactly the same as in the lines before that were imported correctly.

How can I find the problem that the import is complaining about?

I cannot provide a sample of the data because it contains sensitive information.

user3877230

Posted 2015-07-17T12:03:55.457

Reputation: 243

Answers

1

To find these cases, look for any characters that may be interpreted as a delimiter, or a complex or unclosed quote. Remember that if there is a newline as part of a field value earlier in the file, your line numbering may be off, so the line you are looking at may not be the one that the import is complaining about.

Also try importing the CSV file into Excel or OpenOffice to see if those applications treat the file as you expect. That will give you a nice visual way to identify where the problem is.

vallismortis

Posted 2015-07-17T12:03:55.457

Reputation: 382

First of all thank you very much for your answer, i will look over the file. Is there a way to tell The database to ignore this error and import the line anyways and keep on going after that? I think of maybe doing it like that. – user3877230 – 2015-07-17T12:14:41.397

@user3877230 Ignoring the error could very well lead to data loss, as the records that do no match would be dropped, and you may end up with one or more partial records that will be difficult to find after loading. The field length problem will be much easier to address prior to loading than after. – vallismortis – 2015-07-17T12:19:37.240

Okay, thank you very much for your advice, i will look over the file ;) – user3877230 – 2015-07-17T12:31:38.890

0

A solution for me was to copy/paste all of the contents from excel, create a new excel sheet and then paste all of the content.

Then, save it, upload, etc.

I don't know why this worked for me but it did and it's something you can try.

KRS77

Posted 2015-07-17T12:03:55.457

Reputation: 1