Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2023 11:33 PM
Hi, thank you for your answer! Yeah all structures of my csv files are the same.
I used method listdir() to get all names of the files and with "for cykle" I am reading my paths and csv files, and save it into new dataframe.
Important: Actually, if I write "dbfs:/...." it doesn't work (I always get error like file isn't found), but when I use "/dbfs/" it works idk why😥
Anyway this is correct code to read all csv files and concatenate it.
folder_path = "/dbfs/FileStore/aleksandra.frolova@zebra.com/Sales Analysis/"
iles = os.listdir(folder_path) #returns list of all names of csv files in defined folder
df_all_months = pd.DataFrame() #create new DataFrame object
for file in files:
df_of_single_file = pd.read_csv(folder_path + file) #store current dataframe
df_all_months = pd.concat([df_all_months, df_of_single_file])