LoginSignup
33
23

More than 5 years have passed since last update.

jqでcsvをjsonに変換する

Posted at

メモ。jq便利

CSVファイル

foobar.csv

1,foo
2,bar

コマンド

jq -s -R 'split("\n")|map(split(","))|map({"id": .[0], "name": .[1]})' foobar.csv

結果

[
  {
    "id": "1",
    "name": "boo"
  },
  {
    "id": "2",
    "name": "bar"
  }
]
33
23
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
33
23