I have the following code:
os.listdir(\"staging\") # Seperate filename from extension sep = os.sep # Change the casing for n in os.listdir(\"staging\"):
If all you want to do is truncate the file paths to just the filename, you can use os.path.basename:
for file in files: fname = os.path.basename(file) dict_[fname] = (pd.read_csv(file, header=0, dtype=str, encoding='cp1252') .fillna(''))
Example:
os.path.basename('Desktop/test.txt') # 'test.txt'