Validate CSV file against un-matching quotation marks before parsing with opencsv

Viewed 21
new CSVParserBuilder()
.withSeparator(runtimePassedSeparator)
.withIgnoreQuotations(runtimePassedIgnoreQuotations)
.withEscapeChar(runtimePassedEscapeChar).build();

I am trying to parse some CSV files which the caller provides along with following arguments using the parser above: runtimePassedSeparator, runtimePassedSeparator, runtimePassedSeparator

I am running into a problem when the caller passes in the following arguments, along with a file that has open quote which does not close:

runtimePassedSeparator = "\t"
runtimePassedIgnoreQuotations = false
runtimePassedEscapeChar = "\"

Say the file looks like:

name location
Tony Belgium
Troy Brazil
Andy Argen"tina.      <------- Open qoute
Danial Canada
.
.
. (Rest without a quote)

In this case, my CSV parser runs out of memory while parsing. I want to see if there is some sort of validation I can run on the CSV by which I can check that the file is valid rather than it making my program run out of memory.

0 Answers
Related