我需要找到一种将json文件中的数据解析为csv或xlsx的方法。 但是,我在线使用的每个JSON验证器都会给我一个错误,说JSON文件无效。在
JSON文件示例如下:
{"id": "someID1.docx",
"language": {"detected": "cs"},
"title": "Name - Title - FileName",
"text": "Long string of text",
"entities": [
{"standardForm": "Svářečský průkaz", "type": "car"},
{"standardForm": "email1@gmail.com", "type": "email"},
{"standardForm": "english", "type": "languages"},
{"standardForm": "Práce na PC", "type": "abilities"},
{"standardForm": "MS Office", "type": "abilities"},
{"standardForm": "Automechanik", "type": "education"},
{"standardForm": "Střední průmyslová škola", "type": "education"},
{"standardForm": "Angličtina-Němčina", "type": "languages"},
{"standardForm": "mechanic", "type": "position"},
{"standardForm": "Praha", "type": "region"},
{"standardForm": "B2 - středně pokročilý", "type": "en_level"},
{"standardForm": "Skupina B", "type": "drivinglicense"}
]}
{"id": "someID2.pdf",
"language": {"detected": "cs"},
"title": "Name - Title - FileName2",
"text": "Long string of text2",
"entities": [
{"standardForm": "german", "type": "languages"},
{"standardForm": "high school", "type": "education"},
{"standardForm": "Angličtina-Němčina", "type": "languages"},
{"standardForm": "driver", "type": "position"},
{"standardForm": "english", "type": "languages"},
{"standardForm": "university", "type": "education"},
{"standardForm": "email2@seznam.cz", "type": "email"},
{"standardForm": "Středočeský", "type": "region"},
{"standardForm": "Střední", "type": "edulevel"},
{"standardForm": "manager", "type": "lastposition"},
{"standardForm": "? – nerozpoznáno", "type": "de_level"},
{"standardForm": "? – nerozpoznáno", "type": "en_level"},
{"standardForm": "Skupina C", "type": "drivinglicense"}
]}
...
我可以用Python加载这个JSON:
^{pr2}$但我无法将其转换成csv。我需要能够存储所有与所有id相关的实体,最好是csv。有什么办法吗?我需要JSON不同吗?在
谢谢
编辑: 我需要上面例子的csv输出如下:
ID;title;languages;education
someID1.docx;Name-Title-FileName;english,Angličtina-Němčina;Automechanik;Střední Prům. škola
seomeID2.pdf;Name-Title-FileName2; german,Angličtina-Němčina,english;high school, university
用miller(https://github.com/johnkerl/miller/releases/tag/5.4.0),简单地
你有这个CSV
关于选项的一些注意事项:
j2c
将json转换为csvunsparsify
在所有输入记录上打印字段名并集的记录cut -x -r -f
从JSON中删除entities
对象你已经可以雇佣它的熊猫了
相关问题 更多 >
编程相关推荐