How do I read different csv files in folder without concatenating them but just assigning them with the original file name? For example, file with path ...\table1.csv will be named "table1"
I managed to get all file names how do I read each file now?
from os import listdir
from os.path import isfile, join
mypath= ...
onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))]
In other words, instead of reading multiple csv files in pandas like this:
table1 = pd.read_csv(r'C:\Users\username\Folder\Desktop\FolderA\FolderB\Sub_Folder\OneDrive_1_22-06-2022\table1.csv')
table2 = pd.read_csv(r'C:\Users\username\Folder\Desktop\FolderA\FolderB\Sub_Folder\OneDrive_1_22-06-2022\table2.csv')
table3 = pd.read_csv(r'C:\Users\username\Folder\Desktop\FolderA\FolderB\Sub_Folder\OneDrive_1_22-06-2022\table3.csv')
...
is there a better way?