NeoCSV - how to parse a string with unescaped quoted string inside it?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

NeoCSV - how to parse a string with unescaped quoted string inside it?

Paul DeBruicker
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


Reply | Threaded
Open this post in threaded view
|

Re: NeoCSV - how to parse a string with unescaped quoted string inside it?

Sven Van Caekenberghe-2
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 <[hidden email]> 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
>
>