[ENH] reading CSV records ( [er] I do not understand the
behaviour )
David T. Lewis
lewis at mail.msen.com
Sat Aug 14 15:33:59 UTC 2004
Hi Sam,
Thanks for reviewing this. I have attached an improved version.
On Fri, Aug 13, 2004 at 02:35:36AM +0200, sam at rfc1149.net wrote:
>
> In #findToken:escapedBy: and #findTokens:escapedBy: you state:
>
> "Several delimiters in a row are considered as just one separation"
>
> It means that
>
> 'a:b::c' findToken: $: escapedBy: $"
>
> will return three strings instead of the expected four in CSV.
Agreed. The reason that I had written it that way was for consistency
with the existing String>>findTokens method. But I agree with you that,
for parsing a CSV file, it makes more sense if
'a:b::c' findTokens $: escapedBy: $"
answers four tokens rather than three. I changed it to answer four
tokens.
> Also, is this necessary to have two functions rather than converting the
> single character delimeter case to a string on the fly?
Agreed. The single-character version was faster and represented the most
common usage, but it is messy to have two versions of the same thing, so
I got rid of it.
I also added the ability to handle quote characters in the string being parsed:
'this, is, """a, test"' findTokens: ',' escapedBy: '"'
=> an OrderedCollection('this' ' is' ' "a, test')
There are a few more unit tests now to document the changes you suggested,
and I have attempted to add sensible behavior if the parameters are nil or
if the string being parsed is empty.
>
> Sam
Thanks again for the review and suggestions,
Dave
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CsvFileParsing-2-dtl.1.cs.gz
Type: application/x-gunzip
Size: 1002 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20040814/9e8cd215/CsvFileParsing-2-dtl.1.cs.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CsvFileParsingTests-2-dtl.1.cs.gz
Type: application/x-gunzip
Size: 808 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20040814/9e8cd215/CsvFileParsingTests-2-dtl.1.cs.bin
More information about the Squeak-dev
mailing list
|