jq version jq-1.6 on Ubuntu 22.04.2 LTE
Looking to convert large .json file to .csv
json example:
{"_id":{"$oid":"5200a366e36f237975000783"},"derived_form":{"$numberInt":"1"},"intransitive":true,"lemma":"badbad","phonetic":"bɐdbɐt","pos":"VERB","root":{"radicals":"b-d-b-d"},"sources":["Spagnol2011","Falzon2013"],"glosses":[{"gloss":"to fornicate","examples":[]},{"gloss":"to cough a lot","examples":[]}],"norm_freq":{"$numberDouble":"0.0"}}
How do I convert to .csv:
5200a366e36f237975000783, badbad, bɐdbɐt, VERB, true, b-d-b-d, "to fornicate, to cough a lot"
jq '.lemma, .phonetic, .pos, .intransitive, .root.radicals, .glosses.[].gloss'
throws an error in Ubuntu but not at jqplay.org
2
Answers
Your Ubuntu machine is probably not using jq 1.7, which is the version currently running on jqplay.org. This version introduced a new syntax, which you are using with
.glosses.[]
. From the release info:Thus, change your approach to use
.glosses[]
instead:To obtain the desired csv output: