POKI_PUT_TOC_HERE
Whereas the Unix toolkit is made of the separate executables cat, tail, cut, sort, etc., Miller has subcommands, invoked as follows: POKI_INCLUDE_ESCAPED(subcommand-example.txt)HERE
These falls into categories as follows:| Commands | Description |
|---|---|
| cat, cut, head, sort, tac, tail, top, uniq | Analogs of their Unix-toolkit namesakes, discussed below as well as in POKI_PUT_LINK_FOR_PAGE(feature-comparison.html)HERE |
| filter, put, step | awk-like functionality |
| histogram, stats1, stats2 | Statistically oriented |
| group-by, group-like, having-fields | Particularly oriented toward POKI_PUT_LINK_FOR_PAGE(record-heterogeneity.html)HERE, although all Miller commands can handle heterogeneous records |
| count-distinct, rename | These draw from other sources (see also POKI_PUT_LINK_FOR_PAGE(originality.html)HERE): count-distinct is SQL-ish, and rename can be done by sed (which does it faster: see POKI_PUT_LINK_FOR_PAGE(performance.html)HERE). |
--dkvp --idkvp --odkvp --nidx --inidx --onidx --csv --icsv --ocsv --pprint --ipprint --ppprint --right --xtab --ixtab --oxtabThese are as discussed in POKI_PUT_LINK_FOR_PAGE(file-formats.html)HERE, with the exception of --right which makes pretty-printed output right-aligned:
| POKI_RUN_COMMAND{{mlr --opprint cat data/small}}HERE | POKI_RUN_COMMAND{{mlr --opprint --right cat data/small}}HERE |
--rs --irs --ors --fs --ifs --ofs --repifs --ps --ips --ops
--ofmt {format string}
This is the global number format for commands which generate numeric
output, e.g. stats1, stats2, histogram, and
step. Examples:
POKI_CARDIFY(--ofmt %.9le --ofmt %.6lf --ofmt %.0lf)HERE
These are just C printf formats applied to double-precision
numbers. Please don’t use %s or %d. Additionally, if
you use leading with (e.g. %18.12lf) then the output will contain
embedded whitespace, which may not be what you want if you pipe the output to
something else.
| POKI_RUN_COMMAND{{cat a.csv}}HERE | POKI_RUN_COMMAND{{cat b.csv}}HERE | POKI_RUN_COMMAND{{mlr --csv cat a.csv b.csv}}HERE | POKI_RUN_COMMAND{{mlr --icsv --oxtab cat a.csv b.csv}}HERE |
| POKI_RUN_COMMAND{{mlr --opprint cat data/small}}HERE | POKI_RUN_COMMAND{{mlr --opprint cut -f y,x,i data/small}}HERE |
| POKI_RUN_COMMAND{{mlr --opprint filter '($x > 0.5 && $y > 0.5) || ($x < 0.5 && $y < 0.5)' then stats2 -a corr -f x,y data/medium}}HERE |
| POKI_RUN_COMMAND{{mlr --opprint filter '($x > 0.5 && $y < 0.5) || ($x < 0.5 && $y > 0.5)' then stats2 -a corr -f x,y data/medium}}HERE |
| POKI_RUN_COMMAND{{mlr --opprint group-by a data/small}}HERE | POKI_RUN_COMMAND{{mlr --opprint sort a data/small}}HERE |
| POKI_RUN_COMMAND{{mlr cat data/het.dkvp}}HERE | POKI_RUN_COMMAND{{mlr --opprint group-like data/het.dkvp}}HERE |
| POKI_RUN_COMMAND{{mlr cat data/het.dkvp}}HERE |
| POKI_RUN_COMMAND{{mlr having-fields --at-least resource data/het.dkvp}}HERE |
| POKI_RUN_COMMAND{{mlr having-fields --which-are resource,ok,loadsec data/het.dkvp}}HERE |
| POKI_RUN_COMMAND{{mlr --opprint head -n 4 data/medium}}HERE | POKI_RUN_COMMAND{{mlr --opprint head -n 1 -g b data/medium}}HERE |
| POKI_RUN_COMMAND{{mlr --opprint cat data/small}}HERE | POKI_RUN_COMMAND{{mlr --opprint rename i,INDEX,b,COLUMN2 data/small}}HERE |
| POKI_RUN_COMMAND{{sed 's/y/COLUMN5/g' data/small}}HERE |
| POKI_RUN_COMMAND{{mlr rename y,COLUMN5 data/small}}HERE |
| POKI_RUN_COMMAND{{mlr --opprint cat data/small}}HERE | |
| POKI_RUN_COMMAND{{mlr --opprint reorder -f i,b data/small}}HERE | POKI_RUN_COMMAND{{mlr --opprint reorder -e -f i,b data/small}}HERE |
| POKI_RUN_COMMAND{{mlr --oxtab stats1 -a count,sum,avg -f x,y data/medium}}HERE |
| POKI_RUN_COMMAND{{mlr --opprint stats1 -a avg -f x,y -g b then sort b data/medium}}HERE |
| POKI_RUN_COMMAND{{mlr --oxtab put '$x2=$x*$x; $xy=$x*$y; $y2=$y**2' then stats2 -a cov,corr -f x,y,y,y,x2,xy,x2,y2 data/medium}}HERE |
| POKI_RUN_COMMAND{{mlr --opprint put '$x2=$x*$x; $xy=$x*$y; $y2=$y**2' then stats2 -a linreg,r2 -f x,y,y,y,xy,y2 -g a data/medium}}HERE |
| POKI_RUN_COMMAND{{mlr --opprint step -a delta,rsum,counter -f x data/medium | head -15}}HERE |
| POKI_RUN_COMMAND{{mlr --opprint step -a delta,rsum,counter -f x -g a data/medium | head -15}}HERE |
| POKI_RUN_COMMAND{{mlr --icsv --opprint cat a.csv}}HERE | POKI_RUN_COMMAND{{mlr --icsv --opprint cat b.csv}}HERE | POKI_RUN_COMMAND{{mlr --icsv --opprint tac a.csv b.csv}}HERE |
| POKI_RUN_COMMAND{{mlr --icsv --opprint put '$filename=FILENAME' then tac a.csv b.csv}}HERE |
| POKI_RUN_COMMAND{{mlr --opprint tail -n 4 data/colored-shapes.dkvp}}HERE |
| POKI_RUN_COMMAND{{mlr --opprint tail -n 1 -g shape data/colored-shapes.dkvp}}HERE |
| POKI_RUN_COMMAND{{mlr --opprint top -n 4 -f x data/medium}}HERE | POKI_RUN_COMMAND{{mlr --opprint top -n 2 -f x -g a then sort a data/medium}}HERE |
| POKI_RUN_COMMAND{{wc -l data/colored-shapes.dkvp}}HERE |
| POKI_RUN_COMMAND{{mlr uniq -g color,shape data/colored-shapes.dkvp}}HERE |
| POKI_RUN_COMMAND{{mlr --opprint uniq -g color,shape -c then sort color,shape data/colored-shapes.dkvp}}HERE |
| Operators/functions | Description |
|---|---|
| ==, !=, <, <=, >, >=, &&, || | Filter-only. Comparisons are string-valued or number-valued depending on absence/presence of double-quotes in the literal value:
mlr filter '$color != "blue" && $value > 4.2' |
| +, - (unary or binary), *, /, ** | Number-valued. |
| . | String concatenation |
| systime (seconds since epoch), urand | Functions of no arguments returning numbers |
| abs, ceil, cos, exp, floor, log, log10, pow, round, sin, tan | Number-to-number functions with one argument |
| atan2 | Number-to-number functions with two arguments |
| tolower, toupper | String-to-string functions with one argument |