使用 python 下的 jsoncsv 模組進行轉檔
1、首先安裝epel擴充套件源:
$ sudo yum -y install epel-release
2、然後安裝python-pip
$ sudo yum -y install python-pip
$ pip install jsoncsv
Linux下面的操作命令:
cat raw.json |jsoncsv |mkexcel > output.csv cat raw.json |jsoncsv |mkexcel -t xls > output.xls
Windows下面的操作命令:
!type raw.json |jsoncsv |mkexcel > output.csv !type raw.json |jsoncsv |mkexcel -t xls > output.xls
for f in *.json; do cat $f | jsoncsv | mkexcel >> output.csv done
git clone https://github.com/evidens/json2csv.git cd json2csv pip install -r requirements.txt
Basic (convert from a JSON file to a CSV file in same path):
python json2csv.py /path/to/json_file.json /path/to/outline_file.json
Specify CSV file
python json2csv.py /path/to/json_file.json /path/to/outline_file.json -o /some/other/file.csv
For MongoDB (multiple JSON objects per file, which is non-standard JSON):
python json2csv.py --each-line /path/to/json_file.json /path/to/outline_file.json
簡易
json2csv json_file.json -o file.csv
如果你想把所有的JSON文件進入一個發現。 csv文件你可以使用
json2csv *.json -o myfile.csv