-
-
Save gbmele/56a4001cdbd0f842a237aef2f6a26e97 to your computer and use it in GitHub Desktop.
How to convert a JSON file to CSV with AWK
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
# Usage: awk -f json-to-csv.awk values.json > output.csv | |
# Note: You may encounter issues w/ esacping values or missing/empty fields | |
BEGIN{ OFS=""; u=f=l=a=e=""; } | |
/"username"/{ u=$2 } | |
/"first_name"/{ f=$2 } | |
/"last_name"/{ l=$2 } | |
/"asset_type"/{ a=$2 } | |
/"email"/{ e=$2 } | |
{ if(e!="") { print u,f,l,a,e; e="" }} # add for any potentially empty lines | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment