Python: Looping through directory and saving each file using filename as data frame name
问题 In R there is a function called assign which assigns a value to a name in the environment. EG: assign("Hello", 2) > Hello [1] 2 In python I can't seem to do the same. I initially tried: import numpy as np import pandas as pd import os for file in os.listdir('C:\\Users\\Olivia\\Documents'): if file.endswith(".csv"): os.path.splitext(file)[0] = pd.read_csv('C:\\Users\\Olivia\\Documents\\' + file) But I can see this is trying to make a string equal to a file which doesn't work. I managed to get