tags:

views:

350

answers:

4

I'm using the CsvReader library in my Windows Forms application, which is coded in horribly messy VB (I've recently taken over the project.)

I'm currently capable of reading semi-colon separated files without quoting, but I'm having a problem: most of the input has quoted fields, but includes unescaped quote characters within the fields.

I cannot change the input, so I must tackle it somehow. One solution would be to entirely disable quoting -- but I'm not quite sure how to do that...

Any help would be appreciated!

+2  A: 

I've only played a little with this library LINQtoCSV, but I think it may help with quoted fields.

kenny
A: 

How generic do you need it to be? It is quite simple to write your own CSV parser that reads the data into a DataTable.

In some cases parsing the csv file can be as simple as doing a File.ReadAllLines(filename) and then for each line doing a string.Split using a semicolon as the separator to get the columns. Your code will probably be more advanced than that, but if you have specific needs writing it yourself is probably a good idea.

Rune Grimstad
+1  A: 

Check out FileHelpers.

aphoria
A: 

What happen if my csv file's text separator is a comma "," But one of the field "content" is with a lot of comma in within. I cannot edit the CSV file. How can i assign each field to a hashtable? Please advise. Thanks.