Basically I was trying to format the .csv files I have and I was initially working on interactive window to check every step.
When I decided to run the following code in the actual .py file, which has no issue in the interactive window, it raised the following file error FileNotFoundError: [Errno 2] No such file or directory: 'bearingset/health_20_0.csv'.
I think I can just save the files from the interactive window, but I wonder what is the problem I am overlooking that it does not run in the actual code. For information my .py file is in the same folder with a folder called "bearingset" and all the .csv files are in that subfolder
# %%
import pandas as pd
nameList = ["health_20_0.csv",
"comb_20_0.csv",
"inner_20_0.csv",
"outer_20_0.csv",
"health_30_2.csv",
"comb_30_2.csv",
"inner_30_2.csv",
"outer_30_2.csv",
"ball_30_2.csv"
]
for fileName in nameList:
fullName = f'"bearingset/{fileName}"'
df = pd.read_csv(fullName)
df = df.iloc[11:]
df = df[df.columns[0]].apply(lambda x: [float(item) for item in x.split("\t")[0:-1]])
df = pd.DataFrame(df.values.tolist())
df.to_csv(fullName, index=False)