Created
November 6, 2020 17:09
-
-
Save rproenca/bfa316618823ff01c39a5643f90637a7 to your computer and use it in GitHub Desktop.
Transform an arbitrary JSON array into CSV
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cat input.json | jq -r '(map(keys) | add | unique) as $cols | map(. as $row | $cols | map($row[.])) as $rows | $cols, $rows[] | @csv' > output.csv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment