Review of Jesse Phillips's CSV Parser

Jesse Phillips jessekphillips+D at gmail.com
Fri Oct 28 09:41:35 PDT 2011


Vladimir Panteleev Wrote:

> On Fri, 28 Oct 2011 16:18:27 +0300, dsimcha <dsimcha at yahoo.com> wrote:
> 
> > Docs:
> > http://nascent.freeshell.org/programming/D/doc/phobos/std_csv.html
> 
> Documentation should have examples of basic usage at the top. It should be  
> possible to figure out how to use a CSV parser within 10 seconds of  
> looking at the docs.

Sounds good. What kind of example should be first? Maybe something that just gives you an itterable:

auto records = csvText(text);
 
> It looks like this is only a CSV parser, but not a CSV formatter? That's  
> pretty weird. It'd be like std.xml or std.json only having reading  
> functionality.

I have done quite a bit of CSV output and none of them have been the same. The only similarity is surrounding with quotes and escaping quotes.

"\"" ~ text.replace("\"", "\"\"") ~ "\""

The problem is that how your data is stored and where it needs to go is different for each app. I don't see a reason to provide a output function where one must convert their data into a range of struct and specify an output range, when that conversion is the hard part.

I would consider a function that does escaping/quoting only if the element needs it. But such a function couldn't work on an Input Range.


More information about the Digitalmars-d mailing list