NeoCSV - how to parse a string with unescaped quoted string inside it?
Hi - This is on Pharo 7 with Neo-CSV-Core-SvenVanCaekenberghe.28 In a CSV file I have several instances of records like "123","asdf", "one two "three" four five", "5678" When that line is parsed instead of an Array with 4 records '123' 'asdf' 'one two "three" four five' '5678' I instead get '123' 'asdf' '"one two "three" four five"' '"5678"' Is there a standard way or setting for handing strings with quoted strings in them? I'd like to end up with the expected result rather than the result I'm getting. Thanks Paul
Hi Paul, Quotes inside quoted fields must be doubled. See #readQuotedField and #readEndOfQuotedField specifically. See also #testEmbeddedQuotes This is according to https://en.wikipedia.org/wiki/Comma-separated_values and https://tools.ietf.org/html/rfc4180 HTH, Sven BTW: the latest version can be found at https://github.com/svenvc/NeoCSV for more than 2 years, the older repositories are no longer maintained or kept up to date.
On 30 Apr 2020, at 18:39, PAUL DEBRUICKER <pdebruic@gmail.com> wrote:
Hi -
This is on Pharo 7 with Neo-CSV-Core-SvenVanCaekenberghe.28
In a CSV file I have several instances of records like
"123","asdf", "one two "three" four five", "5678"
When that line is parsed instead of an Array with 4 records
'123' 'asdf' 'one two "three" four five' '5678'
I instead get
'123' 'asdf' '"one two "three" four five"' '"5678"'
Is there a standard way or setting for handing strings with quoted strings in them?
I'd like to end up with the expected result rather than the result I'm getting.
Thanks
Paul
participants (2)
-
PAUL DEBRUICKER -
Sven Van Caekenberghe