I have several files in a folder. I can list them via from os.listdir(path)
. Now, I'd like to open those files and name the objects ( pandas DataFrame) after their file names (without extension).
Lets say I have files_list=[file1.csv, file2.csv]
and now I want to avoid:
file1=pd.read_csv(file1.csv) ...
In case I had 100 files the task would be tedious.
Instead, I'd like something like
for file in files_list: file_name = pd.read_csv(file)
this way I could have something like: ''' file_name_1 object (DataFrame from the file_name_1.csv) file_name_2 object (DataFrame frrom the file_name_2.csv) Any help?