优化fix脚本
Showing
1 changed file
with
4 additions
and
2 deletions
| ... | @@ -229,10 +229,12 @@ def main(): | ... | @@ -229,10 +229,12 @@ def main(): |
| 229 | print(f"移除行数: {len(removed)}(同歌手且时长相近)") | 229 | print(f"移除行数: {len(removed)}(同歌手且时长相近)") |
| 230 | print(f"保留行数: {len(kept)}") | 230 | print(f"保留行数: {len(kept)}") |
| 231 | 231 | ||
| 232 | # 写修复后的 CSV | 232 | # 写修复后的 CSV(去掉冗余列) |
| 233 | DROP_COLS = {"topk_hit", "expected_duplicate", "predicted_duplicate", "sample_class"} | ||
| 234 | out_fieldnames = [f for f in fieldnames if f not in DROP_COLS] | ||
| 233 | out_path = Path(args.output) | 235 | out_path = Path(args.output) |
| 234 | with out_path.open("w", newline="", encoding="utf-8") as f: | 236 | with out_path.open("w", newline="", encoding="utf-8") as f: |
| 235 | writer = csv.DictWriter(f, fieldnames=fieldnames) | 237 | writer = csv.DictWriter(f, fieldnames=out_fieldnames, extrasaction="ignore") |
| 236 | writer.writeheader() | 238 | writer.writeheader() |
| 237 | writer.writerows(kept) | 239 | writer.writerows(kept) |
| 238 | print(f"已写入: {out_path}") | 240 | print(f"已写入: {out_path}") | ... | ... |
-
Please register or sign in to post a comment