CSV Import Error: Invalid CSV File


This morning I imported data from several CSV files successfully, with the CSV Import plugin. However 2 files continue to give me the following error message:

Import Error: Invalid CSV File

I have been unable to figure out how these CSV files differ from the others, that loaded successfully. Any ideas?


Are these machine-generated or hand-written CSV files?

It's very easy to accidentally produce an invalid CSV file, but one directly produced by a program should be (usually) fine.

Have you tried opening the offending files in Excel or OpenOffice?

The files were created and edited in Excel. The original files were machine-generated, but they were edited by hand.

Is there a way to identify the errors and correct them in Excel?


Depending on how far away from valid CSV they are, Excel would likely be able to import them and try to automatically fix the errors. If all goes well, that might do the trick. However, the 'fix' might also do unexpected rearrangements of the data, so you'll want to look over the files carefully in Excel to make sure everything is as it should be. Then exporting to CSV should work.

Hope that helps

Thanks for the suggestion, Patrick.

I tried creating new CSV files, by importing the data into Excel. Unfortunately the files still contained unknown errors, and would not load via the CSV import.

I ended up breaking the CSV files down into smaller files, to figure out whether the errors were widespread or specific to certain records. Turned out to be the latter. Once I was able to isolate the offending records within the CSV files, I noticed that many of the fields in these records were blank (intentionally blank on the cataloger's part). I simply deleted these blank fields/columns, and all loaded fine via CSV import. The error appeared to lie in those blank fields, though I do not understand why.

Thanks again for the suggestions!

Without seeing the file, I'd guess that for those records with blank fields, an empty column was not added. That would result in there being inconsistent numbers of fields in the records, which would break things. If you need those fields to be imported (and this guess is accurate), you might try adding empty values for those fields.

Otherwise, glad it's working!