You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.14 16:18:08