| import json | |
| from pathlib import Path | |
| def read_jsonl(path): | |
| with Path(path).open(encoding="utf-8") as f: | |
| for line in f: | |
| yield json.loads(line) | |
| def write_jsonl(path, rows): | |
| with Path(path).open("w", encoding="utf-8") as f: | |
| for row in rows: | |
| f.write(json.dumps(row, ensure_ascii=False) + "\n") | |