Hi Phil,

The CSV parser is missing some features that would make it more  
usable.  Also, the code no longer looks idiomatic to me -- maybe a  
rewrite is in order?

* Take a look at Python's CSV API http://www.python.org/dev/peps/pep-0305/ 
  where they define dialects to be a set of

TUPLE: dialect delimiter quote-char escape-char double-quote skip- 
initial-space
line-terminator quoting ;

The current CSV parser only allows the delimiter to be changed.

* There are multiline fields delimited by the quot-char and I'm not  
sure we support them:

3,"a long
string", more,data

* It could autodetect the separator or detect if there is a column  
header on the first line like Python's Sniffer 
http://docs.python.org/library/csv.html#csv.Sniffer 
   You might return a tuple with the header line and rows.

* For huge CSV files you might want to process it line by line.


The most useful word for me is ``file>csv'' because I'm always reading  
from a file.  One approach is to make  a word ``stream>csv'' that is  
used to implement ``file>csv'', ``string>csv'', etc.  If you want to  
make another word that reads from the standard input, that's fine --  
what's your use case for it, a header line that you want to read  
before reading the rest of the lines?

Maybe some of the features listed above are overdesign, but as there's  
no CSV standard, everybody does something slightly different and not  
supporting a critical feature would make the whole library unusable  
for a particular file.

Doug




On May 26, 2009, at 5:58 AM, Phil Dawes wrote:

> Hi Factor list,
>
> Quick question about factor style:
>
> - Should words taking input use the imput-stream dynamic var by  
> default?
>
> I'm thinking of changing my csv vocab to do this instead of taking a
> stream since I always use 'with-file-reader'. Is this a good idea?
>
> Cheers,
>
> Phil
>
>
>
> ------------------------------------------------------------------------------
> Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
> is a gathering of tech-side developers & brand creativity  
> professionals. Meet
> the minds behind Google Creative Lab, Visual Complexity, Processing, &
> iPhoneDevCamp asthey present alongside digital heavyweights like  
> Barbarian
> Group, R/GA, & Big Spaceship. http://www.creativitycat.com
> _______________________________________________
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to