I am given a file that contains 1000 .csv files(data0,data1,data2..........,data999) and I need to read all those files. So, I tried it on my own. This was my approach: read data0.csv and perform transpose on it and then loop it through all the data*.csv files and then append them. But I was getting an error. Could someone help me out? Reading data0.csv file and transposing it:
df = pd.read_csv('data0.csv')
print (df.head(10))
df_temp = df
df_main = df_temp.transpose()
df_main
new_df = [df_main]
for i in range(1000):
filename = "data%d.csv"%i
df_s = pd.read_csv(filename)
new_df= pd.concat([df_s])
new_df[1]
looping through 1000 files, transposing and concating:
after transposing and appending all the 1000 csv files I should be getting 1000 rows x 150 columns. But I am not getting that.