Skip to content

Instantly share code, notes, and snippets.

@rproenca
Created November 6, 2020 17:09
Show Gist options
  • Save rproenca/bfa316618823ff01c39a5643f90637a7 to your computer and use it in GitHub Desktop.
Save rproenca/bfa316618823ff01c39a5643f90637a7 to your computer and use it in GitHub Desktop.
Transform an arbitrary JSON array into CSV
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