I am trying to get my code to read a folder containing various files. I was hoping to get Jupyter to read each file within that folder and create separate dataframes by taking the names of the files as the dataframe names.
So far I have the code:
import glob
path = r'C:\Users\SemR\Documents\Jupyter\Submissions'
all_files = glob.glob(path + "/*.csv")
li = []
for filename in all_files:
df = pd.read_csv(filename, index_col=None, header=0, usecols=['Date', 'Usage'])
li.append(df)
frame = pd.concat(li, axis=0, ignore_index=True)
This code concatenates the data however I want separate data frames for each so that I can store the values separately. Is there something I can use instead?
Here are examples of how the CSV files look:
These CSV files are in the same folder so I was hoping that when I run my code, new dataframes would be created with the same name as the CSV file name.
Thank you.