(path: Path, rows)
| 24 | |
| 25 | |
| 26 | def write_jsonl(path: Path, rows) -> int: |
| 27 | path.parent.mkdir(parents=True, exist_ok=True) |
| 28 | count = 0 |
| 29 | with path.open("w", encoding="utf-8") as handle: |
| 30 | for row in rows: |
| 31 | handle.write(json.dumps(row, ensure_ascii=False, separators=(",", ":")) + "\n") |
| 32 | count += 1 |
| 33 | return count |
| 34 | |
| 35 | |
| 36 | def copy_if_exists(src: Path, dst: Path) -> None: |