python 转换 json 为 csv (完成)

2023-01-11  本文已影响0人  偷油考拉

通过 jsoncsv 模块

一、安装 jsoncsv module

pip install jsoncsv

安装完毕后,会多一个 jsoncsv 命令

# jsoncsv --help
Usage: jsoncsv [OPTIONS] [INPUT] [OUTPUT]

Options:
  -A, --array               read input file as json array
  -s, --sep SEPARATOR_TYPE  separator
  --safe                    use safe mode
  -r, --restore             restore expanded json
  -e, --expand              expand json (default True)
  --help                    Show this message and exit.

二、转换

cat raw.json | jsoncsv | mkexcel > output.csv
cat raw.json | jsoncsv | mkexcel -t xls > output.xls
上一篇 下一篇

猜你喜欢

热点阅读