reading from file

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Dec 13 11:49:53 PST 2016


On 12/13/2016 08:59 AM, Namal wrote:
> On Tuesday, 13 December 2016 at 16:57:40 UTC, Namal wrote:
>> Sorry if I wasn't clear. The array should be two demensional and each
>> line in text line should be a row in that 2x2 array.
>
> Also, it should be saved as an integer.

Here is another one:

import std.stdio;
import std.algorithm;
import std.array;
import std.conv;

void main() {
     auto a = File("deneme.txt")
              .byLine
              .map!(line => line.splitter(',').map!(to!int).array)
              .array;

     writeln(a);
}

Ali



More information about the Digitalmars-d-learn mailing list