I've got a simple application that opens a tab-delimited text file, and inserts that data into a database.
I'm using this CSV reader to read the data: http://www.codeproject.com/KB/database/CsvReader.aspx
And it is all working just fine!
Now my client has added a new field to the end of the file, which is "ClaimDescription", and in some of these claim descriptions, the data has quotes in it, example:
"SUMISEI MARU NO 2" - sea of Japan
This seems to be causing a major headache for my app. I get an exception which looks like this:
The CSV appears to be corrupt near record '1470' field '26 at position '181'. Current raw data : ...
And in that "raw data", sure enough the claim description field shows data with quotes in it.
I want to know if anyone has ever had this problem before, and got round it? Obviously I can ask the client to change the data they originally send to me, but this is an automated process that they use to generate the tab-delimited file; and I'd rather use that as a last resort.
I was thinking I could maybe open the file using a standard TextReader before hand, escape any quotes, write the content back into a new file, then feed that file into the CSV Reader. It is probably worth mentioning that the average file size of these tab-delimited files is around 40MB.
Any help is greatly appreciated!
Cheers, Sean
Maybe you can open the file with your application and replace each quote with another character and then process it.