I have a folder full of txt files and I want to import each as their own df. I want to call each df the same name as the txt file.
This is what I have to read in all files:
import pandas as pd
import glob
path =r'D:\Path\to\ files'
allFiles = glob.glob(path + "/*.txt")
for file_ in allFiles:
df = pd.read_csv(file_,index_col=None, header=0)
Instead of each df being called df
I would like it to be the *.txt
filename.