-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChangingTimeandSPLdBACahNames.py
More file actions
33 lines (26 loc) · 1.05 KB
/
ChangingTimeandSPLdBACahNames.py
File metadata and controls
33 lines (26 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import os
import pandas as pd
src_folder = r"D:\Project\IITDelhi\onosokki\till\log10\metatdataremovecsv" # original files
dst_folder = r"D:\Project\IITDelhi\onosokki\till\log10\metadataremovChNameCorrectedv2" # output location
os.makedirs(dst_folder, exist_ok=True)
files = [f for f in os.listdir(src_folder) if f.lower().endswith(".csv")]
if not files:
print("no csv files found in", src_folder)
else:
for fname in files:
src_path = os.path.join(src_folder, fname)
dst_path = os.path.join(dst_folder, fname) # same name, new folder
try:
df = pd.read_csv(src_path, header=0)
except Exception as e:
print(f"skipping {fname}: {e}")
continue
cols = df.columns.tolist()
if len(cols) >= 1:
cols[0] = "Time"
if len(cols) >= 2:
cols[1] = "dB"
df.columns = cols
df.to_csv(dst_path, index=False) # write to dst_folder
print(f"written cleaned version of {fname}")
print("Done.")