Skip to content

Latest commit

 

History

History
22 lines (17 loc) · 1.02 KB

generate_csv_file.md

File metadata and controls

22 lines (17 loc) · 1.02 KB

Generate CSV file

Transforming JSON data to a basic CSV is quite easy with jq. The following example is from the JSONPlaceholder service.

http https://jsonplaceholder.typicode.com/posts/1/comments | jq -r '.[] | [.id, .postId, .name, .email] | @csv'
1,1,"id labore ex et quam laborum","Eliseo@gardner.biz"
2,1,"quo vero reiciendis velit similique earum","Jayne_Kuhic@sydney.com"
3,1,"odio adipisci rerum aut animi","Nikita@garfield.biz"
4,1,"alias odio sit","Lew@alysha.tv"
5,1,"vero eaque aliquid doloribus et culpa","Hayden@althea.biz"

Do note the -r/--raw-output option . Is essential and is used to remove the double quotes from the output.

Resources and References