tinycodinglm / misc /misc-0017-p3.jsonl
winapiadmin's picture
Upload folder using huggingface_hub (part 16)
d517dc9 verified
|
Raw History Blame Contribute Delete
683 Bytes
{"type": "session", "harness": "deepseek-harness", "id": "misc-0017-p3", "name": "JSON parsing in Python part 3"}
{"type": "message", "message": {"role": "system", "content": "You are a helpful Python tutor."}}
{"type": "message", "message": {"role": "user", "content": "How do I parse a very large JSON file (several GB) without loading it all into memory in Python?"}}
{"type": "message", "message": {"role": "assistant", "content": "```\n# pip install ijson\nimport ijson\n\nwith open(\"giant_data.json\", \"rb\") as f:\n for log in ijson.items(f, \"logs.item\"):\n if log.get(\"level\") == \"error\":\n print(\"Found an error log block entry!\")\n```"}}