miller/doc/data/map-literal-example-3.sh
2017-02-24 16:33:28 -08:00

19 lines
313 B
Bash
Executable file

mlr --from data/small put -q '
begin {
@o = {
"nrec": 0,
"nkey": {"numeric":0, "non-numeric":0},
};
}
@o["nrec"] += 1;
for (k, v in $*) {
if (is_numeric(v)) {
@o["nkey"]["numeric"] += 1;
} else {
@o["nkey"]["non-numeric"] += 1;
}
}
end {
dump @o;
}
'