MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / load_all_jsonl_files

Function load_all_jsonl_files

experiments/benchmark/export_daily_data.py:66–90  ·  view source on GitHub ↗

加载指定子目录下的所有 JSONL 文件(旧版兼容)

(input_dir: Path, subdir: str, start_date: Optional[str] = None, end_date: Optional[str] = None)

Source from the content-addressed store, hash-verified

64
65
66def 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
93def flatten_profile(record: Dict) -> Dict:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected