This project is read-only.

CSV Parser - Error caused by not using quotes

Jan 30, 2010 at 7:32 AM

Using your latest build from 1/29 I'm getting an error "Record at line : 2 does not have same number of columns as in header." with the following CSV file.

Name,DateTaken
C:\pictures\100_0465.JPG,4/10/2005 11:27 AM
C:\pictures\100_0465.JPG,4/11/2005 12:59 AM
C:\pictures\100_0465.JPG,4/11/2005 12:59 AM

However, if I place single quotes around the values with spaces it works fine.  Shouldn't I only need to use single quotes if the comma delimiter is in the values?  Even more strange, the following CSV works even though the last value doesn't have quotes around it.

Name,DateTaken
G:\pictures\100_0465.JPG,'4/10/2005 11:27 AM'
G:\pictures\100_0465.JPG,'4/11/2005 12:59 AM'
G:\pictures\100_0465.JPG,4/11/2005 12:59 AM

Seems like there is still something strange going on with the handling of single quotes and values with spaces.

Feb 2, 2010 at 9:21 PM

I am experiencing the same exception: "Record at line : 2 does not have the same number of columns as in header." and it clearly does.

Coordinator
Feb 3, 2010 at 1:17 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Coordinator
Feb 3, 2010 at 1:24 AM
Edited Feb 3, 2010 at 1:29 AM

Fixed in source code & updated binaries. Added 5 unit tests using CSV files ( all quotes, no quotes, random quotes, multi-line, with spaces ). Will rebuild the distribtion later in the week.

Looks like I had made a change somewhere along the line to break the CSV parsing.

The UnitTests project now has embedded CSV files that are now used for these 5 unit tests.

Similar file is now part of the _Samples folder as well.

Thanks for posting to the discussion board. These are very helpful!

-Kishore