> On 23 Jan 2015, at 20:53, Hernán Morales Durand <hernan.mora...@gmail.com> 
> wrote:
> 
> Hi Sven,
> 
> 2015-01-23 16:06 GMT-03:00 Sven Van Caekenberghe <s...@stfx.eu>:
> Hi Hernán,
> 
> > On 23 Jan 2015, at 19:50, Hernán Morales Durand <hernan.mora...@gmail.com> 
> > wrote:
> >
> > I used to use a CSV parser from Squeak where I could attach conditional 
> > iterations:
> >
> > csvParser rowsSkipFirst: 2 do: [: row | " some action ignoring first 2 
> > fields on each row " ].
> > csvParser rowsSkipLast: 2 do: [: row | " some action ignoring last 2 fields 
> > on each row " ].
> 
> With NeoCSVParser you can describe how each field is read and converted, 
> using the same mechanism you can ignore fields. Have a look at the senders of 
> #addIgnoredField from the unit tests.
> 
> 
> I am trying to understand the implementation, I see you included 
> #addIgnoredFields: for consecutive fields in 
> Neo-CSV-Core-SvenVanCaekenberghe.21
> A question about usage then, adding ignored field(s) requires adding field 
> types on all other remaining fields?

Yes, like this:

testReadWithIgnoredField
        | input |
        input := (String crlf join: #( '1,2,a,3' '1,2,b,3' '1,2,c,3' '')).
        self 
                assert: ((NeoCSVReader on: input readStream) 
                                        addIntegerField;
                                        addIntegerField;
                                        addIgnoredField;
                                        addIntegerField;
                                        upToEnd)
                equals: {
                        #(1 2 3).
                        #(1 2 3).
                        #(1 2 3).}

>  > csvParser rowsWhere: [ " a condition block " ] do: [ : row | " ... " ].
> 
> NeoCSVParser behaves a bit like a stream and a bit like a collection, there 
> are #next, #atEnd and #upToEnd as well as #do: and  #select:
> 
> 
> I was using the version from the Configuration and missed the 
> #select:[thenDo:] update.

Yes, please use #bleedingEdge, I have to update #stable.

> > csvParser rowsUpTo: 500000 do: [ " some action for rows up to 500000 " ].
> > csvParser rowsFrom: 2000 to: 5000 do: [ " some action for rows between 2000 
> > to 5000 " ].
> 
> Those are not there, you will have to count yourself. #next can be used to 
> #skip.
> 
> 
> Ok
>  
> > I want to replace the parser with NeoCSVReader, is this easily possible 
> > with the current implementation?
> 
> Should work, let me know if you have any problems.
> 
> 
> Thank you Sven!
> 
> Cheers,


Reply via email to