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:
John Kerl 2024-01-20 18:43:49 -05:00 committed by GitHub
parent af021f28d7
commit ac65675ab1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
61 changed files with 481 additions and 221 deletions

View file

@ -0,0 +1 @@
mlr -i json -o csv cat ${CASEDIR}/input.json

View file

@ -0,0 +1,4 @@
a,b,c
1,2,3
4,5,6
7,8,9

View file

@ -0,0 +1,17 @@
[
{
"a": 1,
"b": 2,
"c": 3
},
{
"a": 4,
"b": 5,
"c": 6
},
{
"a": 7,
"b": 8,
"c": 9
}
]

View file

@ -0,0 +1 @@
mlr -i json -o csv cat ${CASEDIR}/input.json

View 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.

View file

@ -0,0 +1,3 @@
a,b,c
1,2,3
4,5,6

View file

@ -0,0 +1,17 @@
[
{
"a": 1,
"b": 2,
"c": 3
},
{
"a": 4,
"b": 5,
"c": 6
},
{
"a": 7,
"X": 8,
"c": 9
}
]

View file

@ -0,0 +1 @@
mlr -i json -o csv cat ${CASEDIR}/input.json

View file

@ -0,0 +1,4 @@
a,b,c
1,2,3
4,5,6,7
7,8,9

View 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
}
]

View file

@ -0,0 +1 @@
mlr -i json -o csv cat ${CASEDIR}/input.json

View file

@ -0,0 +1,4 @@
a,b,c
1,2,3
4,5,
7,8,9

View file

@ -0,0 +1,16 @@
[
{
"a": 1,
"b": 2,
"c": 3
},
{
"a": 4,
"b": 5
},
{
"a": 7,
"b": 8,
"c": 9
}
]

View file

@ -0,0 +1,2 @@
mlr: CSV schema change: first keys "host"; current keys "df/tmp,uptime"
mlr: exiting due to data error.

View file

@ -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

View file

View file

@ -0,0 +1,2 @@
mlr: CSV schema change: first keys "host"; current keys "df/tmp,uptime"
mlr: exiting due to data error.

View file

@ -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

View file

View file

@ -0,0 +1,2 @@
mlr: CSV schema change: first keys "host"; current keys "df/tmp,uptime"
mlr: exiting due to data error.

View file

@ -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

View file

View file

@ -0,0 +1 @@
mlr -i json -o tsv cat ${CASEDIR}/input.json

View file

@ -0,0 +1,4 @@
a b c
1 2 3
4 5 6
7 8 9

View file

@ -0,0 +1,17 @@
[
{
"a": 1,
"b": 2,
"c": 3
},
{
"a": 4,
"b": 5,
"c": 6
},
{
"a": 7,
"b": 8,
"c": 9
}
]

View file

@ -0,0 +1 @@
mlr -i json -o tsv cat ${CASEDIR}/input.json

View 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.

View file

@ -0,0 +1,3 @@
a b c
1 2 3
4 5 6

View file

@ -0,0 +1,17 @@
[
{
"a": 1,
"b": 2,
"c": 3
},
{
"a": 4,
"b": 5,
"c": 6
},
{
"a": 7,
"X": 8,
"c": 9
}
]

View file

@ -0,0 +1 @@
mlr -i json -o tsv cat ${CASEDIR}/input.json

View file

@ -0,0 +1,4 @@
a b c
1 2 3
4 5 6 7
7 8 9

View 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
}
]

View file

@ -0,0 +1 @@
mlr -i json -o tsv cat ${CASEDIR}/input.json

View file

@ -0,0 +1,4 @@
a b c
1 2 3
4 5
7 8 9

View file

@ -0,0 +1,16 @@
[
{
"a": 1,
"b": 2,
"c": 3
},
{
"a": 4,
"b": 5
},
{
"a": 7,
"b": 8,
"c": 9
}
]