【发布时间】:2019-09-05 06:44:39
【问题描述】:
我有一个 350mb 的大 Json 文件,我想从中提取项目。我使用的代码是:
with open("commitsJson3.json","r", encoding="utf-8-sig") as json_file:
data = json.load(json_file)
for elem in data['items']:
for e in elem['commit']:
if 'message' in e:
print(elem['commit'][e])
我得到的错误是:
json.decoder.JSONDecodeError:预期值:第 1 行第 2180 列(字符 2179)
我去了特定的列和行,但没有发现任何问题。我试图通过一些在线验证器来验证我的 json,但它崩溃了,因为它太大了。我可以给你看一些样本,但它太大了,希望你能理解。
{“total_count”:3,“incomplete_results”:“False”,“items”:c“site_admin”:False},“committer”:{“login”:“acosding”,“id”:1539,“ node_id”:“ASJKDHASAD”,“avatar_url”:“https://gits-5.s.fe.se/avatars/u/1329?”,“gravatar_id”:“”,“url”:“https://gits-5.s.fe.se/api/v3/users/acollden”,“html_url”:“https://gits-5.s.fe.se/acollden”,“followers_url”:“ https://https://gits-5.s.fe.se/api/v3/users/acollden/followers", "following_url": "https://gits-5.s.fe.se/api/v3/users/acollden/following{/other_user}", "gists_url": "https://gits-5.s.fe.se/api/v3/users/acollden/gists{/gist_id}", "starred_url": "https://https://gits-5.s.fe.se/api/v3/users/acollden/starred{/owner}{/repo}" ,“subscriptions_url”:“https://https://gits-5.s.fe.se/api/v3/users/acollden/subscriptions”,“organizations_url”:“https://gits-5.s.fe.se/api/v3/users/acollden/orgs”,“repos_url”:“https://https://gits-5.s.fe.se/api/v3/users/acollden/repos”,“events_url”:“https://https://gits-5.s.fe.se/api/v3/users/acollden/events{/privacy}”,“received_events_url”:“ https://https://gits-5.s.fe.se/api/v3/users/acollden/received_events", "type": "用户"
如果 Json 文件在如此大的文件中存在如何验证它的问题等,任何帮助将不胜感激。
谢谢。
【问题讨论】:
-
如果我带你去 json 提取它只会进入第 1111 列,你能分享完整的 json 文件吗,或者至少是一个超出
line 1 column 2180 (char 2179)的提取物@ -
我可以分享。你想让我通过电子邮件或其他方式发送给你吗?它的 350mb
-
@lee-pai-long 你要我把它寄给你吗?
-
350mb 不会传递给大多数电子邮件提供商,您可以尝试查看错误指示的列的提取是否小于 50mb 并使用filebin 吗?
-
@lee-pai-long 这里是filebin.ca/4dlrj3G96n2d/Json4.txt