Created
August 30, 2016 16:58
-
-
Save dcode/61626e5aaa78f37183114f13113c12fe to your computer and use it in GitHub Desktop.
Useful for mapping JSON to CSV when each of the records have the same structure. You can put this into a script and `chmod +x` it.
This file contains hidden or 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
#!/usr/local/bin/jq -s -r -f | |
( map(keys) | add | unique ) as $cols | | |
map(. as $row | $cols | map($row[.])) as $rows | | |
$cols, $rows[] | @csv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment