Using lazy code to process large files

kdevel via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Aug 2 05:47:26 PDT 2017


On Wednesday, 2 August 2017 at 11:44:30 UTC, Martin DraĊĦar wrote:
> Thank you for any hint.

       1 import std.stdio;
       2 import std.string;
       3 import std.algorithm;
       4 import std.conv;
       5
       6 void main ()
       7 {
       8    auto input  = File("input.csv");
       9
      10    auto result = input.byLine()
      11       .filter!(a => a.startsWith("..."))
      12       .map!(a => a.splitter(",")
      13          .map!(b => b.stripLeft)
      14          .join(","))
      15       .join("\n");
      16
      17    auto output = File("output.csv", "w");
      18    output.write(result);
      19 }



More information about the Digitalmars-d-learn mailing list