LoginSignup
2
3

More than 5 years have passed since last update.

JSON to CSV (for Excel)

Posted at

CSV(Character-Separated Values)ってなんだかとってもアレですよね!
某Excelの場合、Tab区切りのUTF-16LE with BOMじゃないと素直には開けなかったりするし。

JSON to CSV(TSV)

ツールは色々あるけど、jqcsvkit がよさげ。

  1. jq -r '(.[]|[.name,.age])|@tsv'
  2. in2csv -fjson|csvformat -TU1'
    • ただのCSVにするなら、in2csv -fjson だけでいい

utf-8 to utf-16LEBOM

nkf または iconv

  1. nkf -W8 -w16L
  2. iconv -f UTF-8 -t UTF-16

繋げば・・・

csvkit×nkfの例:

cat hoge.json|in2csv -fjson|csvformat -TU1|nkf -W8 -w16L>hoge.csv'

ってな感じ。

某M$

utf-8のCSV(Comma-Separated Values)をもっと素直に開けるように対応してくれないかなあ。

2
3
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3