简体   繁体   English

将 JSON 转换为 CSV 的最简单方法(包括数组到字段)

[英]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.

相关问题 将 CSV 转换为 JSON,包括嵌套的对象数组 - Convert CSV to JSON including nested arrays of objects 在javascript中将json的字段转换为数组的最快方法是什么? - What is the fastest way to convert fields of a json into arrays in javascript? 将json数据转换为附加方法的对象的最简单方法? - Easiest way to convert json data into objects with methods attached? 当逗号和引号可能在字段中时,从 CSV 转换为 JSON 的最佳方法是什么? - What is the best way to convert from CSV to JSON when commas and quotations may be in the fields? 使用节点和边缘将CSV数组转换为JSON文件的任何已知方法 - Any known ways to convert CSV arrays to JSON files with nodes & edges Javascript:如何将数组中的JSON数组转换为CSV文件? - Javascript: How to convert an JSON arrays in array into an CSV file? Json到通用深层嵌套数组的CSV转换的通用方法 - Generic way of Json to CSV converting for generic deep nested arrays Javascript:将对象递归转换为字符串(包括子对象和数组),就好像在其周围有引号一样(与JSON.stringify不同) - Javascript: Convert Object to String Recursively (including child objects and arrays) as if there were quotes around it (unlike JSON.stringify) 将JSON转换为数组以在C3中绘制时间序列的更好方法? - Better way to convert JSON to arrays for graphing timeseries in C3? 将JSON转换为数组列表 - Convert JSON to list of arrays
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM