导出为 JSONL 格式
(records: List[Dict], output_path: Path, flatten_func=None)
| 182 | |
| 183 | |
| 184 | def export_to_jsonl(records: List[Dict], output_path: Path, flatten_func=None) -> None: |
| 185 | """导出为 JSONL 格式""" |
| 186 | if not records: |
| 187 | print(" No records to export") |
| 188 | return |
| 189 | |
| 190 | with output_path.open("w", encoding="utf-8") as f: |
| 191 | for r in records: |
| 192 | if flatten_func: |
| 193 | r = flatten_func(r) |
| 194 | f.write(json.dumps(r, ensure_ascii=False) + "\n") |
| 195 | |
| 196 | print(f" Exported {len(records)} records to {output_path}") |
| 197 | |
| 198 | |
| 199 | def main(): |
nothing calls this directly
no outgoing calls
no test coverage detected