From 73f14c6f83231313de7afa08c9db0664a4c5c383 Mon Sep 17 00:00:00 2001 From: Jiang Date: Wed, 7 Jan 2026 17:56:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99=E7=9A=84?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api_ex/remove_sb_columns.py | 32 -------------------------------- 1 file changed, 32 deletions(-) delete mode 100644 api_ex/remove_sb_columns.py diff --git a/api_ex/remove_sb_columns.py b/api_ex/remove_sb_columns.py deleted file mode 100644 index 93f3f70..0000000 --- a/api_ex/remove_sb_columns.py +++ /dev/null @@ -1,32 +0,0 @@ -import csv -from pathlib import Path - -# infile = Path(r"c:\copilot codes\dataclean\Flow_Timedata2025_new_format.csv") -# outfile = Path(r"c:\copilot codes\dataclean\szh_flow_scada.csv") - -infile = Path(r"c:\copilot codes\dataclean\Pressure_Timedata2025_new_format.csv") -outfile = Path(r"c:\copilot codes\dataclean\szh_pressure_scada.csv") - -with infile.open("r", newline="", encoding="utf-8") as f_in: - reader = csv.reader(f_in) - rows = list(reader) - -if not rows: - print("input file is empty") - raise SystemExit(1) - -headers = rows[0] -# keep columns whose header does NOT contain 'SB_' -keep_indices = [i for i,h in enumerate(headers) if 'SB_' not in h] -removed = [h for i,h in enumerate(headers) if 'SB_' in h] - -with outfile.open("w", newline="", encoding="utf-8") as f_out: - writer = csv.writer(f_out) - for row in rows: - # ensure row has same length as headers - if len(row) < len(headers): - row = row + [''] * (len(headers) - len(row)) - newrow = [row[i] for i in keep_indices] - writer.writerow(newrow) - -print(f"Wrote {outfile} — removed {len(removed)} columns containing 'SB_'.")