Converting CSV to JSON in bash

前端 未结 9 1868
梦毁少年i
梦毁少年i 2021-02-04 03:12

Trying to convert a CSV file into a JSON

Here is two sample lines :

-21.3214077;55.4851413;Ruizia cordata
-21.3213078;55.4849803;Cossinia pinnata
         


        
9条回答
  •  抹茶落季
    2021-02-04 03:41

    Here's a python one-liner/script that'll do the trick:

    cat my.csv | python -c 'import csv, json, sys; print(json.dumps([dict(r) for r in csv.DictReader(sys.stdin)]))
    

提交回复
热议问题