[英]Easiest Way to Convert JSON to CSV (Including arrays to fields)
I'm trying to convert my parse.com json data into a csv file, except I have a column of type array, and would like each number within each array to be saved within it's own field.我正在尝试将 parse.com json 数据转换为 csv 文件,但我有一列数组类型,并且希望每个数组中的每个数字都保存在它自己的字段中。
What's the easiest way to do this using the command line or javascript?使用命令行或 javascript 执行此操作的最简单方法是什么?
I've tried several online converters but they fail because my data is too large.我尝试了几个在线转换器,但它们都失败了,因为我的数据太大。 I'm mainly looking for an answer from someone who has converted parse data to the csv format successfully.我主要是在寻找成功将解析数据转换为 csv 格式的人的答案。
Yow might want to use a script, python or php, parse the data in batches, and also write the file in batches of lines by retaining the number of line at some point ( in any case when script fails ) and go back and write from that line.您可能想要使用脚本,python 或 php,批量解析数据,并通过保留某个点的行数(在任何情况下脚本失败时)并返回并从那条线。 A quick pseudo-code example.一个快速的伪代码示例。 based on your attachment根据你的附件
If your json it's formatted line by line :如果您的 json 是逐行格式化的:
Read file , 10 lines at a time读取文件,一次 10 行
batch = 1000 // sample
current = 0
while (current<batch)
for each line :
json_decode() -> create csv string "1,2,3,3.." etc,
write line by appending to file
save line number
current++
end for
endwhile
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.