我有一个千兆字节的JSON文件。该文件由每个不超过几千个字符的JSON对象组成,但是记录之间没有换行符。
使用Python 3和json模块,如何一次从文件读取一个JSON对象到内存?
数据在纯文本文件中。这是类似记录的示例。实际记录包含许多嵌套的字典和列表。
以可读格式记录:
{
"results": {
"__metadata": {
"type": "DataServiceProviderDemo.Address"
},
"Street": "NE 228th",
"City": "Sammamish",
"State": "WA",
"ZipCode": "98074",
"Country": "USA"
}
}
}
实际格式。新记录一个接一个地开始,没有任何中断。
{"results": { "__metadata": {"type": "DataServiceProviderDemo.Address"},"Street": "NE 228th","City": "Sammamish","State": "WA","ZipCode": "98074","Country": "USA" } } }{"results": { "__metadata": {"type": "DataServiceProviderDemo.Address"},"Street": "NE 228th","City": "Sammamish","State": "WA","ZipCode": "98074","Country": "USA" } } }{"results": { "__metadata": {"type": "DataServiceProviderDemo.Address"},"Street": "NE 228th","City": "Sammamish","State": "WA","ZipCode": "98074","Country": "USA" } } }
茅侃侃
相关分类