mirror of
https://github.com/johnkerl/miller.git
synced 2026-01-23 02:14:13 +00:00
mlr sparsify (#1498)
* mlr sparsify * regression-test cases * typofix * Remove mods due to processor-architecture change
This commit is contained in:
parent
cd6d42736f
commit
f5eaf290cf
30 changed files with 424 additions and 19 deletions
|
|
@ -988,6 +988,18 @@ Options:
|
|||
-r Recursively sort subobjects/submaps, e.g. for JSON input.
|
||||
-h|--help Show this message.
|
||||
|
||||
================================================================
|
||||
sparsify
|
||||
Usage: mlr sparsify [options]
|
||||
Unsets fields for which the key is the empty string (or, optionally, another
|
||||
specified value). Only makes sense with output format not being CSV or TSV.
|
||||
Options:
|
||||
-s {filler string} What values to remove. Defaults to the empty string.
|
||||
-f {a,b,c} Specify field names to be operated on; any other fields won't be
|
||||
modified. The default is to modify all fields.
|
||||
-h|--help Show this message.
|
||||
Example: if input is a=1,b=,c=3 then output is a=1,c=3.
|
||||
|
||||
================================================================
|
||||
split
|
||||
Usage: mlr split [options] {filename}
|
||||
|
|
|
|||
1
test/cases/verb-sparsify/0001/cmd
Normal file
1
test/cases/verb-sparsify/0001/cmd
Normal file
|
|
@ -0,0 +1 @@
|
|||
mlr --c2j --from test/input/sparsify-input.csv sparsify
|
||||
0
test/cases/verb-sparsify/0001/experr
Normal file
0
test/cases/verb-sparsify/0001/experr
Normal file
17
test/cases/verb-sparsify/0001/expout
Normal file
17
test/cases/verb-sparsify/0001/expout
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
[
|
||||
{
|
||||
"a": 1,
|
||||
"b": 2,
|
||||
"c": 3
|
||||
},
|
||||
{
|
||||
"a": 4,
|
||||
"b": 5
|
||||
},
|
||||
{},
|
||||
{
|
||||
"a": 7,
|
||||
"b": 8,
|
||||
"c": 9
|
||||
}
|
||||
]
|
||||
1
test/cases/verb-sparsify/0002/cmd
Normal file
1
test/cases/verb-sparsify/0002/cmd
Normal file
|
|
@ -0,0 +1 @@
|
|||
mlr --c2j --from test/input/sparsify-input.csv sparsify -f a
|
||||
0
test/cases/verb-sparsify/0002/experr
Normal file
0
test/cases/verb-sparsify/0002/experr
Normal file
21
test/cases/verb-sparsify/0002/expout
Normal file
21
test/cases/verb-sparsify/0002/expout
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
[
|
||||
{
|
||||
"a": 1,
|
||||
"b": 2,
|
||||
"c": 3
|
||||
},
|
||||
{
|
||||
"a": 4,
|
||||
"b": 5,
|
||||
"c": ""
|
||||
},
|
||||
{
|
||||
"b": "",
|
||||
"c": ""
|
||||
},
|
||||
{
|
||||
"a": 7,
|
||||
"b": 8,
|
||||
"c": 9
|
||||
}
|
||||
]
|
||||
1
test/cases/verb-sparsify/0003/cmd
Normal file
1
test/cases/verb-sparsify/0003/cmd
Normal file
|
|
@ -0,0 +1 @@
|
|||
mlr --c2j --from test/input/sparsify-input.csv sparsify -f b
|
||||
0
test/cases/verb-sparsify/0003/experr
Normal file
0
test/cases/verb-sparsify/0003/experr
Normal file
21
test/cases/verb-sparsify/0003/expout
Normal file
21
test/cases/verb-sparsify/0003/expout
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
[
|
||||
{
|
||||
"a": 1,
|
||||
"b": 2,
|
||||
"c": 3
|
||||
},
|
||||
{
|
||||
"a": 4,
|
||||
"b": 5,
|
||||
"c": ""
|
||||
},
|
||||
{
|
||||
"a": "",
|
||||
"c": ""
|
||||
},
|
||||
{
|
||||
"a": 7,
|
||||
"b": 8,
|
||||
"c": 9
|
||||
}
|
||||
]
|
||||
1
test/cases/verb-sparsify/0004/cmd
Normal file
1
test/cases/verb-sparsify/0004/cmd
Normal file
|
|
@ -0,0 +1 @@
|
|||
mlr --c2j --from test/input/sparsify-input.csv sparsify -f b,c
|
||||
0
test/cases/verb-sparsify/0004/experr
Normal file
0
test/cases/verb-sparsify/0004/experr
Normal file
19
test/cases/verb-sparsify/0004/expout
Normal file
19
test/cases/verb-sparsify/0004/expout
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
[
|
||||
{
|
||||
"a": 1,
|
||||
"b": 2,
|
||||
"c": 3
|
||||
},
|
||||
{
|
||||
"a": 4,
|
||||
"b": 5
|
||||
},
|
||||
{
|
||||
"a": ""
|
||||
},
|
||||
{
|
||||
"a": 7,
|
||||
"b": 8,
|
||||
"c": 9
|
||||
}
|
||||
]
|
||||
1
test/cases/verb-sparsify/0005/cmd
Normal file
1
test/cases/verb-sparsify/0005/cmd
Normal file
|
|
@ -0,0 +1 @@
|
|||
mlr --c2j --from test/input/sparsify-input.csv sparsify -s 1
|
||||
0
test/cases/verb-sparsify/0005/experr
Normal file
0
test/cases/verb-sparsify/0005/experr
Normal file
21
test/cases/verb-sparsify/0005/expout
Normal file
21
test/cases/verb-sparsify/0005/expout
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
[
|
||||
{
|
||||
"b": 2,
|
||||
"c": 3
|
||||
},
|
||||
{
|
||||
"a": 4,
|
||||
"b": 5,
|
||||
"c": ""
|
||||
},
|
||||
{
|
||||
"a": "",
|
||||
"b": "",
|
||||
"c": ""
|
||||
},
|
||||
{
|
||||
"a": 7,
|
||||
"b": 8,
|
||||
"c": 9
|
||||
}
|
||||
]
|
||||
1
test/cases/verb-sparsify/0006/cmd
Normal file
1
test/cases/verb-sparsify/0006/cmd
Normal file
|
|
@ -0,0 +1 @@
|
|||
mlr --c2j --from test/input/sparsify-input.csv sparsify -f a -s 1
|
||||
0
test/cases/verb-sparsify/0006/experr
Normal file
0
test/cases/verb-sparsify/0006/experr
Normal file
21
test/cases/verb-sparsify/0006/expout
Normal file
21
test/cases/verb-sparsify/0006/expout
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
[
|
||||
{
|
||||
"b": 2,
|
||||
"c": 3
|
||||
},
|
||||
{
|
||||
"a": 4,
|
||||
"b": 5,
|
||||
"c": ""
|
||||
},
|
||||
{
|
||||
"a": "",
|
||||
"b": "",
|
||||
"c": ""
|
||||
},
|
||||
{
|
||||
"a": 7,
|
||||
"b": 8,
|
||||
"c": 9
|
||||
}
|
||||
]
|
||||
1
test/cases/verb-sparsify/0007/cmd
Normal file
1
test/cases/verb-sparsify/0007/cmd
Normal file
|
|
@ -0,0 +1 @@
|
|||
mlr --c2j --from test/input/sparsify-input.csv sparsify -f b -s 1
|
||||
0
test/cases/verb-sparsify/0007/experr
Normal file
0
test/cases/verb-sparsify/0007/experr
Normal file
22
test/cases/verb-sparsify/0007/expout
Normal file
22
test/cases/verb-sparsify/0007/expout
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
[
|
||||
{
|
||||
"a": 1,
|
||||
"b": 2,
|
||||
"c": 3
|
||||
},
|
||||
{
|
||||
"a": 4,
|
||||
"b": 5,
|
||||
"c": ""
|
||||
},
|
||||
{
|
||||
"a": "",
|
||||
"b": "",
|
||||
"c": ""
|
||||
},
|
||||
{
|
||||
"a": 7,
|
||||
"b": 8,
|
||||
"c": 9
|
||||
}
|
||||
]
|
||||
1
test/cases/verb-sparsify/0008/cmd
Normal file
1
test/cases/verb-sparsify/0008/cmd
Normal file
|
|
@ -0,0 +1 @@
|
|||
mlr --c2j --from test/input/sparsify-input.csv sparsify -f b,c -s 1
|
||||
0
test/cases/verb-sparsify/0008/experr
Normal file
0
test/cases/verb-sparsify/0008/experr
Normal file
22
test/cases/verb-sparsify/0008/expout
Normal file
22
test/cases/verb-sparsify/0008/expout
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
[
|
||||
{
|
||||
"a": 1,
|
||||
"b": 2,
|
||||
"c": 3
|
||||
},
|
||||
{
|
||||
"a": 4,
|
||||
"b": 5,
|
||||
"c": ""
|
||||
},
|
||||
{
|
||||
"a": "",
|
||||
"b": "",
|
||||
"c": ""
|
||||
},
|
||||
{
|
||||
"a": 7,
|
||||
"b": 8,
|
||||
"c": 9
|
||||
}
|
||||
]
|
||||
5
test/input/sparsify-input.csv
Normal file
5
test/input/sparsify-input.csv
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
a,b,c
|
||||
1,2,3
|
||||
4,5,
|
||||
,,
|
||||
7,8,9
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue