| import json |
| import pandas as pd |
| from pathlib import Path |
|
|
| |
| base_dir = Path("src/esdac") |
| output_dir = Path("src/fuse_esdac/outputs") |
| output_dir.mkdir(parents=True, exist_ok=True) |
|
|
| |
| with open(base_dir / "status.json", "r", encoding="utf-8") as f: |
| data = json.load(f) |
|
|
| |
| processed_items = [item for item in data if item.get("status") == "PROCESSED"] |
|
|
| |
| df = pd.DataFrame(processed_items) |
|
|
| |
| df.rename(columns={"url": "dataset_url"}, inplace=True) |
|
|
| |
| cols_to_drop = [ |
| "request_needed", "status", "notes", |
| "screened_by", "requested_downloaded_by", "processed_by" |
| ] |
| df.drop(columns=cols_to_drop, inplace=True, errors="ignore") |
|
|
| |
| fuse_statuses = [] |
| reasons = [] |
|
|
| for _, row in df.iterrows(): |
| dataset_dir = base_dir / row["name"] |
| fuse_schema = dataset_dir / "fuse_schema.json" |
| fuse_skip = dataset_dir / "fuse_skip.txt" |
|
|
| if fuse_schema.exists(): |
| fuse_statuses.append("FUSED") |
| reasons.append("") |
| elif fuse_skip.exists(): |
| fuse_statuses.append("SKIPPED") |
| try: |
| text = fuse_skip.read_text(encoding="utf-8").strip() |
| except Exception as e: |
| text = f"[Error reading fuse_skip.txt: {e}]" |
| reasons.append(text) |
| else: |
| fuse_statuses.append("AWAIT") |
| reasons.append("") |
|
|
| df["fuse_status"] = fuse_statuses |
| df["reason"] = reasons |
|
|
| |
| output_path = output_dir / "processed_datasets.csv" |
| df.to_csv(output_path, index=False, encoding="utf-8") |
|
|
| print(f"✅ Saved {len(df)} processed datasets to {output_path}") |
|
|
| |
|
|
| |
| output_path = output_dir / "processed_datasets.csv" |
| df.to_csv(output_path, index=False, encoding="utf-8") |
| print(f"✅ Saved {len(df)} processed datasets to {output_path}") |
|
|
| |
| df_fused = df[df["fuse_status"] == "FUSED"].drop(columns=["fuse_status", "reason"]) |
| fused_output_path = output_dir / "fused_datasets.csv" |
| df_fused.to_csv(fused_output_path, index=False, encoding="utf-8") |
| print(f"✅ Saved {len(df_fused)} fused datasets to {fused_output_path}") |
|
|