[Cuis-dev] Can't parse CSV data from file

Hilaire Fernandes hfern at free.fr
Sun Jul 23 04:26:01 PDT 2023


Hi,

I investigate a bit the situation, and the problem seems to come from 
identity comparison of character which could be instance of Character or 
instance of UnicodeCodePoint when read from file. So we have identity 
comparison:

peekSeparator
     ^ self peekChar == separator

There is other method in NeoCSV relying on equal identity between 
characters: #peekFor: #peekQuote

Options to fix it:

  * Make the separator a UnicodePoint, most tests should break.
  * Use equality instead of identity => tested, lock the image
  * other...

I added a test to detect that scenario.



Hilaire


Le 22/07/2023 à 23:58, Hilaire Fernandes via Cuis-dev a écrit :
> Hi,
>
> In the first scenario bellow, the csv content is read correctly, the 
> header is the expect array with 3 items.
>
> In the second scenario, where the same content is read from the 
> timeSlot.csv file, the header is not correctly interpreted, indeed an 
> array with only one string is returned.
>
> It is like if the comma is not interpreted as a field separator.
>
> In the first scenario the data is a String, in the second the file 
> content is instantiated as an UnicodeString.
>
> To reproduce, install NeoCSV package from my forked repository
>
> ( NeoCSVReader on: 'timeSlotName,start,end
> P1,7:45,8:30
> P2,8:35,9:20' readStream) readHeader.
>
> => #('timeSlotName' 'start' 'end') .
>
>
> ( NeoCSVReader on: 'timeSlot.csv' asFileEntry readStream) readHeader.
>
> => #('timeSlotName,start,end') .
>
> Thanks
>
> Hilaire
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20230723/051014d4/attachment.htm>


More information about the Cuis-dev mailing list