Note that there are some explanatory texts on larger screens.

plurals
  1. POQuotes in tab-delimited file
    text
    copied!<p>I've got a simple application that opens a tab-delimited text file, and inserts that data into a database.</p> <p>I'm using this CSV reader to read the data: <a href="http://www.codeproject.com/KB/database/CsvReader.aspx" rel="nofollow noreferrer">http://www.codeproject.com/KB/database/CsvReader.aspx</a></p> <p>And it is all working just fine!</p> <p>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:</p> <blockquote> <p>"SUMISEI MARU NO 2" - sea of Japan</p> </blockquote> <p>This seems to be causing a major headache for my app. I get an exception which looks like this:</p> <blockquote> <p>The CSV appears to be corrupt near record '1470' field '26 at position '181'. Current raw data : ...</p> </blockquote> <p>And in that "raw data", sure enough the claim description field shows data with quotes in it.</p> <p>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.</p> <p>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.</p> <p>Any help is greatly appreciated!</p> <p>Cheers, Sean</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload