I need to iterate through all files in a folder to open all csv files. After I got all the file directory in a list: a. I need to read them and append them to a dataframe with the same column names.
a = [] #empty list
for root, dirs, files in os.walk('C:\\Users\\thaiq\\Week5'):
for file in files:
if file.endswith('.csv') and 'Rentals' in file:
a.append(str(os.path.join(root,file)))
ridedata = pd.DataFrame([]) #empty dataframe
for rides in a:
file = pd.read_csv(rides,header=0) #open each file in list a
ridedata.append(file)
ridedata return empty, plz help :(