【发布时间】:2021-03-24 00:53:08
【问题描述】:
我正在尝试创建一个循环,打开 24 个 csv 文件并将它们连接成一个并创建一个最终的 csv 文件。
我尝试了以下所有方法,直到我需要将它们连接起来......
#Filename
file = '160321-PCU'
fileout = file+'ALL.csv'
#Foor loop to read_csv 24 times - this works... this prints me the dfs
for i in range(1,25):
filename = file+str(i)+'.csv'
df = pd.read_csv(gdrive_url+filename, sep=';',
names=['Date','Time_Decimal','Parameter','Value'])
#This is my attempt to concatenate the dfs...
df_concat = pd.concat([df])
#But as soon as I execute the code below to create ONE csv file to one file, it
#just gives me the 160321-PCU24 df... no concatenate...
df_concat.to_csv(gdrive_url_out+fileout, index=True)
【问题讨论】: