[lug] Convert JSON to CSV - adding header line

Jed S. Baer blug at jbaer.cotse.net
Sat Jan 16 10:20:07 MST 2021


On Sat, 16 Jan 2021 09:55:54 -0700
dlwillson at thegeek.nu wrote:

> Two ways come to mind:
> 
> echo the header line, then append the data lines, to the CSV.
> 
> echo $HEADERS > csv
> jq 'expression' >> csv
> 
> Or, create a headers json same layout as the other, but with headers as
> values, instead of actual values, and query it, like you're querying
> users.

Sure, it's easy, particularly in bash. I assume the same ease in
Powershell, or WSL. I was just hoping to keep it all compact and
self-contained.

-- 
All operating systems suck, but Linux just sucks less
 - Linus Torvalds


More information about the LUG mailing list