File size: 340 Bytes
b227dc8 | 1 2 3 4 5 6 7 8 9 10 11 12 13 | 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")
|