Menu

#35 How to validate unmatched/unescaped quotes?

v1.0 (example)
wont-fix
nobody
None
5
2016-05-18
2015-07-28
Steiny
No

Hi,

I am currently using version 2.2 and I was trying to work out why CSVReader.readAll() was returning an empty String array. It turns out that there was an unescaped quotes which caused the parser to keep reading multiple lines until it ran out of input (since there were no more quotes to end the value.

A simple example is:
"bad,csv

I noticed that in version 2.2 and 2.3 of the CSVReader there was the following comment in the readNext() method: "should throw if still pending?"

I think the answer to that question is yes. I have tried version 3.4 and, although that comment didn't seem to be there, the behaviour is the same.

Is there a way to validate this case?

Cheers

Discussion

  • Scott Conway

    Scott Conway - 2015-08-02

    Good question. I do not believe there is an easy way to validate.

    Try building a CSVReader with strictQuotes set to false - this is supposed to tell openCSV that the fields are between separators instead of between quotes.

     
  • Andrew Rucker Jones

    Steiny: Is this issue resolved?

     
    • Steiny

      Steiny - 2016-05-18

      I'm not too sure. I vaguely remember trying Scott's suggestion but I can't say whether it worked or not. I ended up having other issues and I went with Apache Commons CSV which I still had to patch to get exactly what I wanted.

       
  • Andrew Rucker Jones

    • status: open --> wont-fix
     
  • Andrew Rucker Jones

    Since no one can verify the continued existance of this issue, I'm closing the ticket. Thanks to Steiny for the speedy response!

     

Log in to post a comment.

MongoDB Logo MongoDB