Convert JSON to CSV

To convert a json file to CSV you will need a linux program called jq.

INPUTFILE="inputfile-with-json"
OUTPUTFILE="outputfile-formatted.csv"
jq -r '(.[0] | keys_unsorted) as $keys | $keys, map([.[ $keys[] ]])[] | @csv' ${INPUTFILE} > ${OUTPUTFILE}

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.