转换JSon array data to CSV.
zencore-json2csv的Python项目详细描述
将json数组数据转换为csv。
安装
pip install zencore-json2csv
用法
E:\>json2csv --help Usage: json2csv [OPTIONS] Options: -f, --file FILENAME Input file name, use - for stdin. --file-encoding TEXT Input file encoding. -o, --output FILENAME Output file name, use - for stdout. --output-encoding TEXT Output file encoding. -k, --keys TEXT Output field names. Comma separated string list. -p, --path TEXT Path of the data. --help Show this message and exit.
示例1
输入:
[ [1,2,3], [2,3,4] ]
输出:
1,2,3 2,3,4
命令:
cat input.txt | json2csv -o output.txt
例2
输入:
[ {"f1": 11, "f2": 12, "f3": 13}, {"f1": 21, "f3": 23, "f2": 22} ]
输出:
11,12,13 21,22,23
命令:
cat input.txt | json2csv -o output.txt -k f1,f2,f3
例3
输入:
{ "data": { "list": [ [1,2,3], [2,3,4], ] } }
输出:
1,2,3 2,3,4
命令:
cat input.txt | json2csv -o output.txt -p data.list