Today I Learned - Rocky Kev

TIL using jq to turn JSON into CSV

POSTED ON:

TAGS:

I've been learning about jq recently.

jq is like sed for JSON data - you can use it to slice and filter and map and transform structured data with the same ease that sed, awk, grep and friends let you play with text.

One of the benefits is turning a JSON response into CSV.

jq -r '(map(keys) | add | unique) as $cols | map(. as $row | $cols | map($row[.])) as $rows | $cols, $rows[] | @csv'

Via https://stackoverflow.com/a/32965227


Related TILs

Tagged:

TIL using the find command

find [path] -user [username] [options]

TIL Find Command

I wanted to look for files with a specific extension. You can do that with ls *.(mp3|exe|mp4)

TIL playing Tetris inside Zsh

If you're using a Mac, you're probably using iTerm. 1. Load iTerm 2. launch emacs. 3. Launch Tetris.