Advertisement
metalx1000

Parsing User JSON Data to CSV

Jun 24th, 2024 (edited)
854
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.50 KB | None | 0 0
  1. #get csv2json script here:
  2. # https://pastebin.com/qZc1V5Nm
  3.  
  4. wget -qO- "https://randomuser.me/api/?nat=us&results=100&format=csv"  > users.csv
  5. csv2json -i users.csv -o users.json -f pretty
  6.  
  7. cut -d\, -f1,2,3,7 users.csv
  8.  
  9. jq -r '.[]|(.phone+","+.email+","+."dob.age")' users.json
  10. jq -r '.[]|(.phone+"|"+.email+"|"+."dob.age")' users.json
  11.  
  12. jq -r '.[]|(."name.first"+","+."name.last"+","+."dob.age"+","+.phone)' users.json
  13. jq -r '.[]|"\(."name.first"),\(."name.last"),\(."dob.age"), \(.phone)"' users.json
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement