美文网首页
python 转换 json 为 csv (完成)

python 转换 json 为 csv (完成)

作者: 偷油考拉 | 来源:发表于2023-01-11 10:28 被阅读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

相关文章

网友评论

      本文标题:python 转换 json 为 csv (完成)

      本文链接:https://www.haomeiwen.com/subject/blgcbrtx.html