objectsAsRows

Contruct a lazy random-access-range (ndslice)

@safe pure nothrow @nogc
objectsAsRows
(
bool allowMissingFields = true
T
)
(
return scope const(StringMap!T)[] objects
,
return scope const(string)[] header
)
if (
isImplicitlyConvertible!(const T, T)
)

Return Value

Type: auto

a lazy 1-dimensional slice of lazy 1-dimensionalal slices

Examples

import mir.algebraic_alias.csv: T = CsvAlgebraic;
import mir.algebraic: Nullable;
import mir.date: Date;
import mir.test: should;

auto o1 = ["a" : 1.T,
           "b" : 2.0.T]
    .StringMap!T;
auto o2 = ["b" : true.T,
           "c" : false.T]
    .StringMap!T;
auto o3 = ["c" : Date(2021, 12, 12).T,
           "d" : 3.T]
    .StringMap!T;

alias NCA = Nullable!T;

auto rows = [o1, o2, o3].objectsAsRows(["b", "c"]);
rows.should == [
    // a                           b
    [NCA(2.0.T),  NCA(null)],
    [NCA(true.T), NCA(false.T)],
    [NCA(null),   NCA(Date(2021, 12, 12))],
];

static assert(is(typeof(rows[0][0]) == NCA));

// evaluate
import mir.ndslice.fuse: fuse;
static assert(is(typeof(rows.fuse) == Slice!(NCA*, 2))); 

Meta