Need to create multiple CSV files at the location
csv_data="D:\Desktop\DS\DSDA\Assignment\"
for a in range(60):
csv_data = csv_data + str(a)
csv_data = DataFrameDict[a].to_csv(csv_data.csv, index = False, header=True)`
csv_data = ""
I have tried:
file.with_suffix('.csv'), index = False)
also didnt work
First/better path for me would be to use pathlib ; however, let's stick to ur question. I would suggest adding the csv to the string addition:
csv_data="D:\Desktop\DS\DSDA\Assignment\"
for a in range(60):
#add the '.csv' here
csv_data = csv_data + str(a)+'.csv'
csv_data = DataFrameDict[a].to_csv(csv_data, index = False, header=True)`
#what is this line for?
csv_data = ""
let's see if it works
This code is able to create 60 CSV files using one dataframe:
csv_data="D:\Desktop\DS\DSDA\Assignment\"
for a in range(60):
csv_data = csv_data + str(a)
csv_data = DataFrameDict[a].to_csv(csv_data+str(".csv"), index = False, header=True)
csv_data = ""
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.