加载指定子目录下的所有 JSONL 文件(旧版兼容)
(input_dir: Path, subdir: str, start_date: Optional[str] = None, end_date: Optional[str] = None)
| 64 | |
| 65 | |
| 66 | def load_all_jsonl_files(input_dir: Path, subdir: str, start_date: Optional[str] = None, end_date: Optional[str] = None) -> List[Dict]: |
| 67 | """加载指定子目录下的所有 JSONL 文件(旧版兼容)""" |
| 68 | records = [] |
| 69 | dir_path = input_dir / subdir |
| 70 | |
| 71 | if not dir_path.exists(): |
| 72 | print(f" [Warning] Directory not found: {dir_path}") |
| 73 | return records |
| 74 | |
| 75 | for f in sorted(dir_path.glob("*.jsonl")): |
| 76 | date_str = f.stem |
| 77 | |
| 78 | if start_date and date_str < start_date: |
| 79 | continue |
| 80 | if end_date and date_str > end_date: |
| 81 | continue |
| 82 | |
| 83 | with f.open("r", encoding="utf-8") as file: |
| 84 | for line in file: |
| 85 | line = line.strip() |
| 86 | if line: |
| 87 | records.append(json.loads(line)) |
| 88 | |
| 89 | print(f" Loaded {len(records)} records from {subdir}") |
| 90 | return records |
| 91 | |
| 92 | |
| 93 | def flatten_profile(record: Dict) -> Dict: |
nothing calls this directly
no outgoing calls
no test coverage detected