I'm using Lumenworks Fast CsvReader and the exception error occurred while reading the Kelley Blue Book's file:
The CSV appears to be corrupt near record '1281' field '5 at position '1169'
The file is tab delimited. In there I found double quotes was used but I don't see how to escape it and resume normally because it's tab delimited data.
--Characters in Text File--
12345 2013 RAV4 "Sport" Sport Utility 4D 2
--Source Code--
using(CsvReader csvReader = new CsvReader(new StreamReader(filePath), false, '\t', '"', '"', '#', LumenWorks.Framework.IO.Csv.ValueTrimmingOptions.QuotedOnly))
{
}
I tried a number of different CsvReader setting with no luck. What do you use that works great? I do not have that much trouble with comma delimited files.
There is a mssing closing bracket behind the
StreamReader:I have tested it with your line above (forced tab as delimiter in the file) and it worked.
Output was:
Update, according your comment and the provided text-file:
This csv-reader enables to handle
FillErrorandParseErrorexceptions raised by invalid or corrupt data. So you handle them to get more informations and for logging purposes.For example:
You need to listen to this event:
I have recognized that it doesn't work to use
"as quoting character with your text-file since some fields contain data likeRAV4 "Sport" Sport Utility 4D. So the field itself contains the quoting character. Instead you don't need one at all since no fields are quoted. So don't provide one in the constructor or set it as'\0'. Then this runs without a problem: