https://d.puremagic.com/issues/show_bug.cgi?id=11682

           Summary: Lazier std.csv.csvReader
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nob...@puremagic.com
        ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 2013-12-04 05:11:24 PST ---
Given a "data.csv" file that contains:

1,2,3,4
5,6,7,8
9,10,11,12
13,14,15,16



With dmd 2.065alpha you can read its contents like this using csvReader:

void main() {
    import std.stdio, std.csv, std.file;
    "data.csv".readText.csvReader!int.writeln;
}


Output:

[[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]


If the file is large you can also read the lines lazily (same output):

void main() {
    import std.stdio, std.csv, std.file, std.algorithm;
    "data.csv".File.byLine.map!(r => r.csvReader!int.front).writeln;
}


But I think csvReader should also support reading lines lazily like this:

"data.csv".File.csvReader!int.writeln;

Or something like this:

"data.csv".File.byLine.csvReader!int.writeln;

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to