csvToStringMatrix

@trusted pure
Slice!(string*, 2)
csvToStringMatrix
(
return scope string text
,
char separator = ','
,
char quote = '"'
,
char comment = '\0'
,
ubyte skipRows = 0
,
bool fill = true
,
bool skipEmptyLines = true
)

Return Value

Type: Slice!(string*, 2)

$(NDSLICEREF slice, Slice)!(string*, 2).

Examples

// empty lines are allowed by default
auto data = `012,abc,"mno pqr",0` ~ "\n\n" ~ `982,def,"stuv wx",1`
    ~ "\n" ~ `78,ghijk,"yx",2`;

auto matrix = data.csvToStringMatrix();

import mir.ndslice.slice: Slice, SliceKind;

static assert(is(typeof(matrix) == Slice!(string*, 2)));

import mir.test: should;
matrix.should ==
[[`012`, `abc`, `mno pqr`, `0`], [`982`, `def`, `stuv wx`, `1`], [`78`, `ghijk`, `yx`, `2`]];

import mir.ndslice.dynamic: transposed;
auto transp = matrix.transposed;
static assert(is(typeof(transp) == Slice!(string*, 2, SliceKind.universal)));

transp.should ==
[[`012`, `982`, `78`], [`abc`, `def`, `ghijk`], [`mno pqr`, `stuv wx`, `yx`], [`0`, `1`, `2`]];

See Also

Meta