6 May 15:37
Re: Bug in CSV parser
From: Stefan Scholl <stesch@...>
Subject: Re: Bug in CSV parser
Newsgroups: gmane.comp.lang.factor.general
Date: 2008-05-06 13:37:34 GMT
Subject: Re: Bug in CSV parser
Newsgroups: gmane.comp.lang.factor.general
Date: 2008-05-06 13:37:34 GMT
Or the application just ignores every row with the first field
starting with "#".
"123,456,789\n#stuff\n111,222,333" <string-reader> csv
[ first "#" head? not ] filter .
{ { "123" "456" "789" } { "111" "222" "333" } }
! Or:
: process-row ( seq -- n )
dup first "#" head? not
[ 0 [ string>number + ] reduce ]
[ 0 ] if ;
"123,456,789\n#stuff\n111,222,333" <string-reader> csv [ process-row ] map .
{ 1368 0 666 }
Slava Pestov <slava@...> wrote:
> This would be a good approach if the csv parser had an alternative
> entry point taking an array of strings.
>
> Then I could do
>
> "foo.txt" ascii file-lines [ "#" head? not ] filter csv-lines
>
> Slava
>
> On May 6, 2008, at 1:20 AM, Stefan Scholl wrote:
>
>> I haven't seen comments in any csv documentation so far. This
>> kind of in-band signalling should be handled by the application
>> itself and not by the library.
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
> Don't miss this year's exciting event. There's still time to save $100.
> Use priority code J8TL2D2.
> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
--
--
Web (en): http://www.no-spoon.de/ -*- Web (de): http://www.frell.de/
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
RSS Feed