miller icon indicating copy to clipboard operation
miller copied to clipboard

DKVP's incremental implicit keys

Open agguser opened this issue 6 months ago • 0 comments

Currently, a DVKP field without a key uses its index as its key. E.g.

$ echo 'a,z=b,c' | mlr cat
1=a,z=b,3=c

, but I find that implicit keys should be incremental (like Lua table (({'a', z='b', 'c'})[2] == 'c'), so please add a flag to make this, e.g.:

$ echo 'a,z=b,c' | mlr --inc-keys cat
1=a,z=b,2=c

.

Workaround:

$ echo 'a,z=b,c' | perl -pe'my $i; s/(^|,)\K(?![^=,]*=)/ ++$i."=" /eg'
1=a,z=b,2=c

agguser avatar Jun 14 '25 15:06 agguser