std.csv.csvReader operating on File.byLine()

Ali Çehreli acehreli at yahoo.com
Sun Oct 7 15:16:57 PDT 2012


On 10/07/2012 02:42 PM, Rene Zwanenburg wrote:

 > For the sake of cleanliness (and Walter's article on component
 > programming ;) ), is there a way to treat a file as an InputRange of
 > characters? I think this is quite a common use case.

I've just discovered the undocumented byRecord:

Again, assuming that deneme.txt contains:

1,2,3.5
6,7,8.5

import std.stdio;

void main()
{
     auto someFile = File("deneme.txt");

     writeln(someFile.byRecord!(int, int, float)("%s,%s,%s"));
}

And there is std.algorithm.joiner:

     writeln(someFile.byLine.joiner);

There must be something more straightforward though. :)

Ali



More information about the Digitalmars-d-learn mailing list