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","[email protected]"
2,1,"quo vero reiciendis velit similique earum","[email protected]"
3,1,"odio adipisci rerum aut animi","[email protected]"
4,1,"alias odio sit","[email protected]"
5,1,"vero eaque aliquid doloribus et culpa","[email protected]"

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

Resources and References