mirror of
https://github.com/johnkerl/miller.git
synced 2026-01-23 02:14:13 +00:00
Auto-unsparsify CSV and TSV on output (#1479)
* Auto-unsparsify CSV * Update unit-test cases * More unit-test cases * Key-change handling for CSV output * Same for TSV, with unit-test and doc updates
This commit is contained in:
parent
af021f28d7
commit
ac65675ab1
61 changed files with 481 additions and 221 deletions
1
test/cases/io-csv-auto-unsparsify/at/cmd
Normal file
1
test/cases/io-csv-auto-unsparsify/at/cmd
Normal file
|
|
@ -0,0 +1 @@
|
|||
mlr -i json -o csv cat ${CASEDIR}/input.json
|
||||
0
test/cases/io-csv-auto-unsparsify/at/experr
Normal file
0
test/cases/io-csv-auto-unsparsify/at/experr
Normal file
4
test/cases/io-csv-auto-unsparsify/at/expout
Normal file
4
test/cases/io-csv-auto-unsparsify/at/expout
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
a,b,c
|
||||
1,2,3
|
||||
4,5,6
|
||||
7,8,9
|
||||
17
test/cases/io-csv-auto-unsparsify/at/input.json
Normal file
17
test/cases/io-csv-auto-unsparsify/at/input.json
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
[
|
||||
{
|
||||
"a": 1,
|
||||
"b": 2,
|
||||
"c": 3
|
||||
},
|
||||
{
|
||||
"a": 4,
|
||||
"b": 5,
|
||||
"c": 6
|
||||
},
|
||||
{
|
||||
"a": 7,
|
||||
"b": 8,
|
||||
"c": 9
|
||||
}
|
||||
]
|
||||
1
test/cases/io-csv-auto-unsparsify/key-change/cmd
Normal file
1
test/cases/io-csv-auto-unsparsify/key-change/cmd
Normal file
|
|
@ -0,0 +1 @@
|
|||
mlr -i json -o csv cat ${CASEDIR}/input.json
|
||||
2
test/cases/io-csv-auto-unsparsify/key-change/experr
Normal file
2
test/cases/io-csv-auto-unsparsify/key-change/experr
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
mlr: CSV schema change: first keys "a,b,c"; current keys "a,X,c"
|
||||
mlr: exiting due to data error.
|
||||
3
test/cases/io-csv-auto-unsparsify/key-change/expout
Normal file
3
test/cases/io-csv-auto-unsparsify/key-change/expout
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
a,b,c
|
||||
1,2,3
|
||||
4,5,6
|
||||
17
test/cases/io-csv-auto-unsparsify/key-change/input.json
Normal file
17
test/cases/io-csv-auto-unsparsify/key-change/input.json
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
[
|
||||
{
|
||||
"a": 1,
|
||||
"b": 2,
|
||||
"c": 3
|
||||
},
|
||||
{
|
||||
"a": 4,
|
||||
"b": 5,
|
||||
"c": 6
|
||||
},
|
||||
{
|
||||
"a": 7,
|
||||
"X": 8,
|
||||
"c": 9
|
||||
}
|
||||
]
|
||||
0
test/cases/io-csv-auto-unsparsify/key-change/should-fail
Normal file
0
test/cases/io-csv-auto-unsparsify/key-change/should-fail
Normal file
1
test/cases/io-csv-auto-unsparsify/over/cmd
Normal file
1
test/cases/io-csv-auto-unsparsify/over/cmd
Normal file
|
|
@ -0,0 +1 @@
|
|||
mlr -i json -o csv cat ${CASEDIR}/input.json
|
||||
0
test/cases/io-csv-auto-unsparsify/over/experr
Normal file
0
test/cases/io-csv-auto-unsparsify/over/experr
Normal file
4
test/cases/io-csv-auto-unsparsify/over/expout
Normal file
4
test/cases/io-csv-auto-unsparsify/over/expout
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
a,b,c
|
||||
1,2,3
|
||||
4,5,6,7
|
||||
7,8,9
|
||||
18
test/cases/io-csv-auto-unsparsify/over/input.json
Normal file
18
test/cases/io-csv-auto-unsparsify/over/input.json
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
[
|
||||
{
|
||||
"a": 1,
|
||||
"b": 2,
|
||||
"c": 3
|
||||
},
|
||||
{
|
||||
"a": 4,
|
||||
"b": 5,
|
||||
"c": 6,
|
||||
"d": 7
|
||||
},
|
||||
{
|
||||
"a": 7,
|
||||
"b": 8,
|
||||
"c": 9
|
||||
}
|
||||
]
|
||||
1
test/cases/io-csv-auto-unsparsify/under/cmd
Normal file
1
test/cases/io-csv-auto-unsparsify/under/cmd
Normal file
|
|
@ -0,0 +1 @@
|
|||
mlr -i json -o csv cat ${CASEDIR}/input.json
|
||||
0
test/cases/io-csv-auto-unsparsify/under/experr
Normal file
0
test/cases/io-csv-auto-unsparsify/under/experr
Normal file
4
test/cases/io-csv-auto-unsparsify/under/expout
Normal file
4
test/cases/io-csv-auto-unsparsify/under/expout
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
a,b,c
|
||||
1,2,3
|
||||
4,5,
|
||||
7,8,9
|
||||
16
test/cases/io-csv-auto-unsparsify/under/input.json
Normal file
16
test/cases/io-csv-auto-unsparsify/under/input.json
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
[
|
||||
{
|
||||
"a": 1,
|
||||
"b": 2,
|
||||
"c": 3
|
||||
},
|
||||
{
|
||||
"a": 4,
|
||||
"b": 5
|
||||
},
|
||||
{
|
||||
"a": 7,
|
||||
"b": 8,
|
||||
"c": 9
|
||||
}
|
||||
]
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
mlr: CSV schema change: first keys "host"; current keys "df/tmp,uptime"
|
||||
mlr: exiting due to data error.
|
||||
|
|
@ -1,35 +1,2 @@
|
|||
host
|
||||
jupiter
|
||||
|
||||
df/tmp,uptime
|
||||
2.43MB,32345sec
|
||||
|
||||
host
|
||||
saturn
|
||||
|
||||
df/tmp,uptime
|
||||
1.34MB,234214132sec
|
||||
|
||||
host
|
||||
mars
|
||||
|
||||
df/tmp,uptime
|
||||
4.97MB,345089805sec
|
||||
|
||||
host
|
||||
jupiter
|
||||
|
||||
df/tmp,uptime
|
||||
0.04MB,890sec
|
||||
|
||||
host
|
||||
mars
|
||||
|
||||
df/tmp,uptime
|
||||
8.55MB,787897777sec
|
||||
|
||||
host
|
||||
saturn
|
||||
|
||||
df/tmp,uptime
|
||||
9.47MB,234289080sec
|
||||
|
|
|
|||
0
test/cases/io-multi/0010/should-fail
Normal file
0
test/cases/io-multi/0010/should-fail
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
mlr: CSV schema change: first keys "host"; current keys "df/tmp,uptime"
|
||||
mlr: exiting due to data error.
|
||||
|
|
@ -1,35 +1,2 @@
|
|||
host
|
||||
jupiter
|
||||
|
||||
df/tmp,uptime
|
||||
2.43MB,32345sec
|
||||
|
||||
host
|
||||
saturn
|
||||
|
||||
df/tmp,uptime
|
||||
1.34MB,234214132sec
|
||||
|
||||
host
|
||||
mars
|
||||
|
||||
df/tmp,uptime
|
||||
4.97MB,345089805sec
|
||||
|
||||
host
|
||||
jupiter
|
||||
|
||||
df/tmp,uptime
|
||||
0.04MB,890sec
|
||||
|
||||
host
|
||||
mars
|
||||
|
||||
df/tmp,uptime
|
||||
8.55MB,787897777sec
|
||||
|
||||
host
|
||||
saturn
|
||||
|
||||
df/tmp,uptime
|
||||
9.47MB,234289080sec
|
||||
|
|
|
|||
0
test/cases/io-multi/0033/should-fail
Normal file
0
test/cases/io-multi/0033/should-fail
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
mlr: CSV schema change: first keys "host"; current keys "df/tmp,uptime"
|
||||
mlr: exiting due to data error.
|
||||
|
|
@ -1,23 +1 @@
|
|||
jupiter
|
||||
|
||||
2.43MB,32345sec
|
||||
|
||||
saturn
|
||||
|
||||
1.34MB,234214132sec
|
||||
|
||||
mars
|
||||
|
||||
4.97MB,345089805sec
|
||||
|
||||
jupiter
|
||||
|
||||
0.04MB,890sec
|
||||
|
||||
mars
|
||||
|
||||
8.55MB,787897777sec
|
||||
|
||||
saturn
|
||||
|
||||
9.47MB,234289080sec
|
||||
|
|
|
|||
0
test/cases/io-multi/0034/should-fail
Normal file
0
test/cases/io-multi/0034/should-fail
Normal file
1
test/cases/io-tsv-auto-unsparsify/at/cmd
Normal file
1
test/cases/io-tsv-auto-unsparsify/at/cmd
Normal file
|
|
@ -0,0 +1 @@
|
|||
mlr -i json -o tsv cat ${CASEDIR}/input.json
|
||||
0
test/cases/io-tsv-auto-unsparsify/at/experr
Normal file
0
test/cases/io-tsv-auto-unsparsify/at/experr
Normal file
4
test/cases/io-tsv-auto-unsparsify/at/expout
Normal file
4
test/cases/io-tsv-auto-unsparsify/at/expout
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
a b c
|
||||
1 2 3
|
||||
4 5 6
|
||||
7 8 9
|
||||
17
test/cases/io-tsv-auto-unsparsify/at/input.json
Normal file
17
test/cases/io-tsv-auto-unsparsify/at/input.json
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
[
|
||||
{
|
||||
"a": 1,
|
||||
"b": 2,
|
||||
"c": 3
|
||||
},
|
||||
{
|
||||
"a": 4,
|
||||
"b": 5,
|
||||
"c": 6
|
||||
},
|
||||
{
|
||||
"a": 7,
|
||||
"b": 8,
|
||||
"c": 9
|
||||
}
|
||||
]
|
||||
1
test/cases/io-tsv-auto-unsparsify/key-change/cmd
Normal file
1
test/cases/io-tsv-auto-unsparsify/key-change/cmd
Normal file
|
|
@ -0,0 +1 @@
|
|||
mlr -i json -o tsv cat ${CASEDIR}/input.json
|
||||
2
test/cases/io-tsv-auto-unsparsify/key-change/experr
Normal file
2
test/cases/io-tsv-auto-unsparsify/key-change/experr
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
mlr: TSV schema change: first keys "a b c"; current keys "a X c"
|
||||
mlr: exiting due to data error.
|
||||
3
test/cases/io-tsv-auto-unsparsify/key-change/expout
Normal file
3
test/cases/io-tsv-auto-unsparsify/key-change/expout
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
a b c
|
||||
1 2 3
|
||||
4 5 6
|
||||
17
test/cases/io-tsv-auto-unsparsify/key-change/input.json
Normal file
17
test/cases/io-tsv-auto-unsparsify/key-change/input.json
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
[
|
||||
{
|
||||
"a": 1,
|
||||
"b": 2,
|
||||
"c": 3
|
||||
},
|
||||
{
|
||||
"a": 4,
|
||||
"b": 5,
|
||||
"c": 6
|
||||
},
|
||||
{
|
||||
"a": 7,
|
||||
"X": 8,
|
||||
"c": 9
|
||||
}
|
||||
]
|
||||
0
test/cases/io-tsv-auto-unsparsify/key-change/should-fail
Normal file
0
test/cases/io-tsv-auto-unsparsify/key-change/should-fail
Normal file
1
test/cases/io-tsv-auto-unsparsify/over/cmd
Normal file
1
test/cases/io-tsv-auto-unsparsify/over/cmd
Normal file
|
|
@ -0,0 +1 @@
|
|||
mlr -i json -o tsv cat ${CASEDIR}/input.json
|
||||
0
test/cases/io-tsv-auto-unsparsify/over/experr
Normal file
0
test/cases/io-tsv-auto-unsparsify/over/experr
Normal file
4
test/cases/io-tsv-auto-unsparsify/over/expout
Normal file
4
test/cases/io-tsv-auto-unsparsify/over/expout
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
a b c
|
||||
1 2 3
|
||||
4 5 6 7
|
||||
7 8 9
|
||||
18
test/cases/io-tsv-auto-unsparsify/over/input.json
Normal file
18
test/cases/io-tsv-auto-unsparsify/over/input.json
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
[
|
||||
{
|
||||
"a": 1,
|
||||
"b": 2,
|
||||
"c": 3
|
||||
},
|
||||
{
|
||||
"a": 4,
|
||||
"b": 5,
|
||||
"c": 6,
|
||||
"d": 7
|
||||
},
|
||||
{
|
||||
"a": 7,
|
||||
"b": 8,
|
||||
"c": 9
|
||||
}
|
||||
]
|
||||
1
test/cases/io-tsv-auto-unsparsify/under/cmd
Normal file
1
test/cases/io-tsv-auto-unsparsify/under/cmd
Normal file
|
|
@ -0,0 +1 @@
|
|||
mlr -i json -o tsv cat ${CASEDIR}/input.json
|
||||
0
test/cases/io-tsv-auto-unsparsify/under/experr
Normal file
0
test/cases/io-tsv-auto-unsparsify/under/experr
Normal file
4
test/cases/io-tsv-auto-unsparsify/under/expout
Normal file
4
test/cases/io-tsv-auto-unsparsify/under/expout
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
a b c
|
||||
1 2 3
|
||||
4 5
|
||||
7 8 9
|
||||
16
test/cases/io-tsv-auto-unsparsify/under/input.json
Normal file
16
test/cases/io-tsv-auto-unsparsify/under/input.json
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
[
|
||||
{
|
||||
"a": 1,
|
||||
"b": 2,
|
||||
"c": 3
|
||||
},
|
||||
{
|
||||
"a": 4,
|
||||
"b": 5
|
||||
},
|
||||
{
|
||||
"a": 7,
|
||||
"b": 8,
|
||||
"c": 9
|
||||
}
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue