Pandas读取JSON转Excel时报ValueError:All arrays must be of the same length的问题求助
Pandas读取JSON转Excel时报ValueError:All arrays must be of the same length的问题求助
大家好,我现在在跑一个简单的Python测试,想要读取JSON文件并输出到Excel里,但碰到了这个错误:
ValueError("All arrays must be of the same length")
下面是我的测试用JSON文件示例:
{ "content": [ { "id": "test_id", "url": "http://www.google.com/", "path1": "dir1/dir1_subdir_1/hello.txt", "path2": "external://hello.txt", "revision": "613592", "ChangedDate": "2024-01-01T17:00:00+00:00", "ChangedRevision": "12345", "tags": [], "Revision": { "id": "2468", "revision": "987654", "revisionSource": "google", "url": "http://www.google.com" } } ], "requestId": "12345", "errors": [], "warnings": [], "information": [], "isValid": true }
我不需要输出文件里包含最后5个字段(也就是requestId、errors、warnings、information、isValid这些内容)。
这是我目前的Python代码:
import pandas as pd df = pd.read_json("simple.json",).to_excel("json_output.xlsx", index=False)
有没有大佬能帮我看看问题出在哪,该怎么修改才能正确导出我需要的内容到Excel里呀?
备注:内容来源于stack exchange,提问作者D Chase
相关产品推荐
相关产品推荐

