如何在jupyter笔记本中导入ndjson文件

2024-10-01 00:17:08 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试了下面的代码,但它不起作用

import json
with open("/Users/elton/20210228test2.ndjson") as f:
    test2data = ndjson.load(f)

Tags: 代码importjsonaswithloadopenusers
1条回答
网友
1楼 · 发布于 2024-10-01 00:17:08

这对我有用import ndjson而不是import json。更多信息请参见:https://pypi.org/project/ndjson/

import ndjson

# load from file-like objects
with open('data.ndjson') as f:
    data = ndjson.load(f)

相关问题 更多 >