2

I am trying to parse a CSV file with openCSV CSVReader, I have some records in the file like this...

"npg6851",,"Wonderful reminder\","This is perfect, I always wanted", ,"5","Nancy88","published"

As this answer indicated, that sequence \" is interpreted as a literal non-enclosing quote and the parser tries to read everything afterwards are one value (regarding any comma delimiters).

Is this considered valid according to CSV specifications?

AbuMariam
  • 3,282
  • 13
  • 49
  • 82
  • 3
    There is no CSV spec; it's a wild tangle. This is one of the biggest challenges with CSV. Various CSV parsers have configuration options regarding quoting. – chrylis -cautiouslyoptimistic- Mar 06 '19 at 16:35
  • @chrylis there actually is one: https://tools.ietf.org/html/rfc4180 from 2005, populair programs like libreoffice follow the RFC, and by doing so, they even support csv's containing newlines in the values – Ferrybig Mar 07 '19 at 07:03

1 Answers1

1

Looks like according to the CSV RFC, there are no issues with using backslash in a quoted CSV field, so it is valid.

This makes sense, because this issue is strictly Java-based (and any other programming language that uses \ as its escape character). Solving this, however, seems to have a very difficult solution.

Matt
  • 902
  • 7
  • 20