首页 > 解决方案 > 在 Python 中解析格式错误的 JSON 数据集的问题

问题描述

我很难从故意格式错误的 JSON 数据集创建熊猫数据框。我遇到的困难是,dirtyjson 似乎只是解析并将一个条目写入输出文件,而不是整个 JSON 文件:

# load json files into python
with open ('neither.json') as neither:    

neither_data = dirtyjson.load(neither)

neither_parsed = json.dumps(neither_data)

with open ('json_file_neither','w') as outfile:

json.dump(neither_data, outfile)

如果有人能指出如何纠正这个问题,或者如果有人能提出比 dityjson 更好的方法来清理格式错误的 JSON,我们将不胜感激。

谢谢,院长

标签: pythonjsonstringdictionaryjupyter-notebook

解决方案


推荐阅读