csvReader read file byLine()?

Jens Mueller jens.k.mueller at gmx.de
Thu Jun 21 13:29:51 PDT 2012


Timon Gehr wrote:
> On 06/21/2012 02:17 PM, Jens Mueller wrote:
> >Hi,
> >
> >I used std.csv for reading a CSV file.
> >Thanks a lot to Jesse for writing and adding std.csv to Phobos.
> >Using it is fairly straightforward but I miss one thing. Very commonly
> >you need to read a CSV file. With std.csv that boils down to
> >
> >auto records = csvReader!(Record)(readText(filename));
> >
> >But csvReader won't parse from File(filename, "r").byLine() even though
> >that is an InputRange, isn't it? That means I always have to use
> >readText. All IO happens that very moment.
> >Shouldn't the csvReader support lazy reading from a file like this
> >
> >auto file = File(filename, "r");
> >auto records = csvReader!(Record)(file.byLine());
> >
> >Am I missing something? Was this left out for a reason or an oversight?
> >
> >Jens
> 
> You might make use of std.algorithm.joiner.

The problem is that csvParser expects a range with elements of type
dchar. Any idea why that is required for CSV parsing?

Jens


More information about the Digitalmars-d mailing list