Skip to content

Instantly share code, notes, and snippets.

@jmpinit
Created August 23, 2020 14:46
Show Gist options
  • Select an option

  • Save jmpinit/d961e792902b87f6ffccf0d69d900413 to your computer and use it in GitHub Desktop.

Select an option

Save jmpinit/d961e792902b87f6ffccf0d69d900413 to your computer and use it in GitHub Desktop.
JSON to CSV with JQ.
# The input file contains an array of objects where each object contains fields that we would like to extract
# as the rows of our CSV file
# https://stedolan.github.io/jq/
# -r is to output raw text instead of JSON
# foo and bar are the fields we are interested in
jq -r 'map([.foo, .bar] | join(", ")) | join("\n")' input.json > output.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment