Stop parsing line at a specified line ending

Nov 19, 2012 at 8:46 PM

Some of our users submit files that have a single quote which messes up the entire file.
Example:

Name,Address,age
Bob,123 Main St,55
Jim,55 "North Ave,23
Jill,Street Name,34
Jane,Street Name,42

Because the third row (Jim,55 "North Ave,23) doesn't have a closing quote, all lines after it fail because it gets treated as a one line with line-breaks.

In our specific case we don't allow line breaks.  Each row constitutes one record. Is there a way to tell the CsvReader to act accordingly?  To not treat the rest of the file as "the next line" or stop when it encounters a line-ending?

I hope that makes sense...

Coordinator
Nov 20, 2012 at 9:30 AM

Hi INeedADip,

You're essentially asking for a CSV reader to not read CSV, so no. You have some options:

  1. Set the value delimiter to something other than a double quote. eg. set it to the '|' character. As long as you don't have commas in your values, this will work. However, you will get the double quotes in the values you read from KBCsv.
  2. Massage the data before it is passed to KBCsv.

HTH,
Kent