miller
miller copied to clipboard
`join` prefixes (`--lp`, `--rp`) not applied to unpaired records (`--ul`, `--ur`)
$ <<. cat >old.csv
color,count
red,3467
orange,670
yellow,27
blue,6944
.
$ <<. cat >new.csv
color,count
red,3472
blue,6838
orange,694
purple,12
.
$ # with --lp, --rp
<new.csv mlr --c2p \
join -f old.csv --ul --ur -j color --lp=old_ --rp=new_ \
+ unsparsify
color old_count new_count count
red 3467 3472 -
blue 6944 6838 -
orange 670 694 -
purple - - 12
yellow - - 27
$ # vs with `rename` on both files
<new.csv mlr --c2p \
rename count,new_count \
+ join -f <(mlr -c rename count,old_count old.csv) --ul --ur -j color \
+ unsparsify
color old_count new_count
red 3467 3472
blue 6944 6838
orange 670 694
purple - 12
yellow 27 -
(The example is based on https://miller.readthedocs.io/en/latest/misc-examples/#showing-differences-between-successive-queries)
Was biten by this and had to resort to temp files to create unique header labels. Would be nice to do this somehow 'inbound'