mirror of
https://github.com/johnkerl/miller.git
synced 2026-01-23 02:14:13 +00:00
Implement mlr uniq -x (#1457)
* mlr uniq -x * unit-test cases * make dev
This commit is contained in:
parent
f4cf166358
commit
0e3a54ed68
46 changed files with 238 additions and 35 deletions
|
|
@ -96,6 +96,7 @@ Same as uniq -c.
|
|||
|
||||
Options:
|
||||
-f {a,b,c} Field names for distinct count.
|
||||
-x {a,b,c} Field names to exclude for distinct count: use each record's others instead.
|
||||
-n Show only the number of distinct values. Not compatible with -u.
|
||||
-o {name} Field name for output count. Default "count".
|
||||
Ignored with -u.
|
||||
|
|
@ -1320,6 +1321,7 @@ count-distinct. For uniq, -f is a synonym for -g.
|
|||
|
||||
Options:
|
||||
-g {d,e,f} Group-by-field names for uniq counts.
|
||||
-x {a,b,c} Field names to exclude for uniq: use each record's others instead.
|
||||
-c Show repeat counts in addition to unique values.
|
||||
-n Show only the number of distinct values.
|
||||
-o {name} Field name for output count. Default "count".
|
||||
|
|
|
|||
1
test/cases/verb-uniq/uniq-c-x-change/cmd
Normal file
1
test/cases/verb-uniq/uniq-c-x-change/cmd
Normal file
|
|
@ -0,0 +1 @@
|
|||
mlr --dkvp uniq -c -x flag,k,index,quantity,rate test/input/example-with-changed-keys.dkvp
|
||||
0
test/cases/verb-uniq/uniq-c-x-change/experr
Normal file
0
test/cases/verb-uniq/uniq-c-x-change/experr
Normal file
7
test/cases/verb-uniq/uniq-c-x-change/expout
Normal file
7
test/cases/verb-uniq/uniq-c-x-change/expout
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
color=yellow,shape=triangle,count=1
|
||||
color=red,shape=square,count=2
|
||||
weird=red,shape=circle,count=1
|
||||
color=purple,shape=triangle,count=2
|
||||
color=red,shape=square,odd=77.19910000,count=1
|
||||
color=yellow,shape=circle,count=2
|
||||
color=purple,shape=square,count=1
|
||||
1
test/cases/verb-uniq/uniq-c-x-het/cmd
Normal file
1
test/cases/verb-uniq/uniq-c-x-het/cmd
Normal file
|
|
@ -0,0 +1 @@
|
|||
mlr --dkvp uniq -c -x flag,k,index,quantity,rate test/input/example.dkvp
|
||||
0
test/cases/verb-uniq/uniq-c-x-het/experr
Normal file
0
test/cases/verb-uniq/uniq-c-x-het/experr
Normal file
6
test/cases/verb-uniq/uniq-c-x-het/expout
Normal file
6
test/cases/verb-uniq/uniq-c-x-het/expout
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
color=yellow,shape=triangle,count=1
|
||||
color=red,shape=square,count=3
|
||||
color=red,shape=circle,count=1
|
||||
color=purple,shape=triangle,count=2
|
||||
color=yellow,shape=circle,count=2
|
||||
color=purple,shape=square,count=1
|
||||
1
test/cases/verb-uniq/uniq-c-x-long/cmd
Normal file
1
test/cases/verb-uniq/uniq-c-x-long/cmd
Normal file
|
|
@ -0,0 +1 @@
|
|||
mlr --dkvp uniq -c -x flag,k,index,quantity,rate test/input/example-with-extra-keys.dkvp
|
||||
0
test/cases/verb-uniq/uniq-c-x-long/experr
Normal file
0
test/cases/verb-uniq/uniq-c-x-long/experr
Normal file
7
test/cases/verb-uniq/uniq-c-x-long/expout
Normal file
7
test/cases/verb-uniq/uniq-c-x-long/expout
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
color=yellow,shape=triangle,count=1
|
||||
color=red,shape=square,count=3
|
||||
color=red,shape=circle,count=1
|
||||
color=purple,shape=triangle,extra=here,count=1
|
||||
color=purple,shape=triangle,count=1
|
||||
color=yellow,shape=circle,count=2
|
||||
color=purple,shape=square,count=1
|
||||
1
test/cases/verb-uniq/uniq-c-x-short/cmd
Normal file
1
test/cases/verb-uniq/uniq-c-x-short/cmd
Normal file
|
|
@ -0,0 +1 @@
|
|||
mlr --dkvp uniq -c -x flag,k,index,quantity,rate test/input/example-with-missing-keys.dkvp
|
||||
0
test/cases/verb-uniq/uniq-c-x-short/experr
Normal file
0
test/cases/verb-uniq/uniq-c-x-short/experr
Normal file
6
test/cases/verb-uniq/uniq-c-x-short/expout
Normal file
6
test/cases/verb-uniq/uniq-c-x-short/expout
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
color=yellow,shape=triangle,count=1
|
||||
color=red,shape=square,count=3
|
||||
shape=circle,count=1
|
||||
color=purple,shape=triangle,count=2
|
||||
color=yellow,shape=circle,count=2
|
||||
color=purple,shape=square,count=1
|
||||
1
test/cases/verb-uniq/uniq-x-change/cmd
Normal file
1
test/cases/verb-uniq/uniq-x-change/cmd
Normal file
|
|
@ -0,0 +1 @@
|
|||
mlr --dkvp uniq -x flag,k,index,quantity,rate test/input/example-with-changed-keys.dkvp
|
||||
0
test/cases/verb-uniq/uniq-x-change/experr
Normal file
0
test/cases/verb-uniq/uniq-x-change/experr
Normal file
7
test/cases/verb-uniq/uniq-x-change/expout
Normal file
7
test/cases/verb-uniq/uniq-x-change/expout
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
color=yellow,shape=triangle
|
||||
color=red,shape=square
|
||||
weird=red,shape=circle
|
||||
color=purple,shape=triangle
|
||||
color=red,shape=square,odd=77.19910000
|
||||
color=yellow,shape=circle
|
||||
color=purple,shape=square
|
||||
1
test/cases/verb-uniq/uniq-x-het/cmd
Normal file
1
test/cases/verb-uniq/uniq-x-het/cmd
Normal file
|
|
@ -0,0 +1 @@
|
|||
mlr --dkvp uniq -x flag,k,index,quantity,rate test/input/example.dkvp
|
||||
0
test/cases/verb-uniq/uniq-x-het/experr
Normal file
0
test/cases/verb-uniq/uniq-x-het/experr
Normal file
6
test/cases/verb-uniq/uniq-x-het/expout
Normal file
6
test/cases/verb-uniq/uniq-x-het/expout
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
color=yellow,shape=triangle
|
||||
color=red,shape=square
|
||||
color=red,shape=circle
|
||||
color=purple,shape=triangle
|
||||
color=yellow,shape=circle
|
||||
color=purple,shape=square
|
||||
1
test/cases/verb-uniq/uniq-x-long/cmd
Normal file
1
test/cases/verb-uniq/uniq-x-long/cmd
Normal file
|
|
@ -0,0 +1 @@
|
|||
mlr --dkvp uniq -x flag,k,index,quantity,rate test/input/example-with-extra-keys.dkvp
|
||||
0
test/cases/verb-uniq/uniq-x-long/experr
Normal file
0
test/cases/verb-uniq/uniq-x-long/experr
Normal file
7
test/cases/verb-uniq/uniq-x-long/expout
Normal file
7
test/cases/verb-uniq/uniq-x-long/expout
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
color=yellow,shape=triangle
|
||||
color=red,shape=square
|
||||
color=red,shape=circle
|
||||
color=purple,shape=triangle,extra=here
|
||||
color=purple,shape=triangle
|
||||
color=yellow,shape=circle
|
||||
color=purple,shape=square
|
||||
1
test/cases/verb-uniq/uniq-x-short/cmd
Normal file
1
test/cases/verb-uniq/uniq-x-short/cmd
Normal file
|
|
@ -0,0 +1 @@
|
|||
mlr --dkvp uniq -x flag,k,index,quantity,rate test/input/example-with-missing-keys.dkvp
|
||||
0
test/cases/verb-uniq/uniq-x-short/experr
Normal file
0
test/cases/verb-uniq/uniq-x-short/experr
Normal file
6
test/cases/verb-uniq/uniq-x-short/expout
Normal file
6
test/cases/verb-uniq/uniq-x-short/expout
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
color=yellow,shape=triangle
|
||||
color=red,shape=square
|
||||
shape=circle
|
||||
color=purple,shape=triangle
|
||||
color=yellow,shape=circle
|
||||
color=purple,shape=square
|
||||
10
test/input/example-with-changed-keys.dkvp
Normal file
10
test/input/example-with-changed-keys.dkvp
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
color=yellow,shape=triangle,flag=true,k=1,index=11,quantity=43.6498,rate=9.8870
|
||||
color=red,shape=square,flag=true,k=2,index=15,quantity=79.2778,rate=0.0130
|
||||
weird=red,shape=circle,flag=true,k=3,index=16,quantity=13.8103,rate=2.9010
|
||||
color=red,shape=square,flag=false,k=4,index=48,quantity=77.5542,rate=7.4670
|
||||
color=purple,shape=triangle,flag=false,k=5,index=51,quantity=81.2290,rate=8.5910
|
||||
color=red,shape=square,flag=false,k=6,index=64,odd=77.1991,rate=9.5310
|
||||
color=purple,shape=triangle,flag=false,k=7,index=65,quantity=80.1405,rate=5.8240
|
||||
color=yellow,shape=circle,flag=true,k=8,index=73,quantity=63.9785,rate=4.2370
|
||||
color=yellow,shape=circle,flag=true,k=9,index=87,quantity=63.5058,rate=8.3350
|
||||
color=purple,shape=square,flag=false,k=10,index=91,quantity=72.3735,rate=8.2430
|
||||
10
test/input/example-with-extra-keys.dkvp
Normal file
10
test/input/example-with-extra-keys.dkvp
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
color=yellow,shape=triangle,flag=true,k=1,index=11,quantity=43.6498,rate=9.8870
|
||||
color=red,shape=square,flag=true,k=2,index=15,quantity=79.2778,rate=0.0130
|
||||
color=red,shape=circle,flag=true,k=3,index=16,quantity=13.8103,rate=2.9010
|
||||
color=red,shape=square,flag=false,k=4,index=48,quantity=77.5542,rate=7.4670
|
||||
color=purple,shape=triangle,flag=false,k=5,index=51,quantity=81.2290,rate=8.5910,extra=here
|
||||
color=red,shape=square,flag=false,k=6,index=64,quantity=77.1991,rate=9.5310
|
||||
color=purple,shape=triangle,flag=false,k=7,index=65,quantity=80.1405,rate=5.8240
|
||||
color=yellow,shape=circle,flag=true,k=8,index=73,quantity=63.9785,rate=4.2370
|
||||
color=yellow,shape=circle,flag=true,k=9,index=87,quantity=63.5058,rate=8.3350
|
||||
color=purple,shape=square,flag=false,k=10,index=91,quantity=72.3735,rate=8.2430
|
||||
10
test/input/example-with-missing-keys.dkvp
Normal file
10
test/input/example-with-missing-keys.dkvp
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
color=yellow,shape=triangle,flag=true,k=1,index=11,quantity=43.6498,rate=9.8870
|
||||
color=red,shape=square,flag=true,k=2,index=15,quantity=79.2778,rate=0.0130
|
||||
shape=circle,flag=true,k=3,index=16,quantity=13.8103,rate=2.9010
|
||||
color=red,shape=square,flag=false,k=4,index=48,quantity=77.5542,rate=7.4670
|
||||
color=purple,shape=triangle,flag=false,index=51,quantity=81.2290,rate=8.5910
|
||||
color=red,shape=square,flag=false,k=6,index=64,quantity=77.1991,rate=9.5310
|
||||
color=purple,shape=triangle,flag=false,k=7,index=65,quantity=80.1405,rate=5.8240
|
||||
color=yellow,shape=circle,flag=true,k=8,index=73,quantity=63.9785,rate=4.2370
|
||||
color=yellow,shape=circle,flag=true,k=9,index=87,quantity=63.5058,rate=8.3350
|
||||
color=purple,shape=square,flag=false,k=10,index=91,quantity=72.3735,rate=8.2430
|
||||
10
test/input/example.dkvp
Normal file
10
test/input/example.dkvp
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
color=yellow,shape=triangle,flag=true,k=1,index=11,quantity=43.6498,rate=9.8870
|
||||
color=red,shape=square,flag=true,k=2,index=15,quantity=79.2778,rate=0.0130
|
||||
color=red,shape=circle,flag=true,k=3,index=16,quantity=13.8103,rate=2.9010
|
||||
color=red,shape=square,flag=false,k=4,index=48,quantity=77.5542,rate=7.4670
|
||||
color=purple,shape=triangle,flag=false,k=5,index=51,quantity=81.2290,rate=8.5910
|
||||
color=red,shape=square,flag=false,k=6,index=64,quantity=77.1991,rate=9.5310
|
||||
color=purple,shape=triangle,flag=false,k=7,index=65,quantity=80.1405,rate=5.8240
|
||||
color=yellow,shape=circle,flag=true,k=8,index=73,quantity=63.9785,rate=4.2370
|
||||
color=yellow,shape=circle,flag=true,k=9,index=87,quantity=63.5058,rate=8.3350
|
||||
color=purple,shape=square,flag=false,k=10,index=91,quantity=72.3735,rate=8.2430
|
||||
Loading…
Add table
Add a link
Reference in a new issue