This is my first post. I want to loop or iterate in a directory to import each of the files as a separate DataFrame with a name similar (at least with the numeration) to the name of its file. After a lot of research I still do not know how to do it. Obviously I am a very beginner :-)
My code is:
Main_folder = os.getcwd()
Folders = os.listdir('.')
for file in Folders:
data= pd.read_csv(file, sep="\t", header=0)
data.columns=data.columns.str.strip()
where for instance Folders
is a list of files names including the file extension. e.g.:
Folders=['01_load.TXT', '02_load.TXT', '03_load.TXT']
What I need is just to import all files to my work space such:
Load_01=pd.read_csv('01_load.TXT', sep="\t", header=0)
Load_02=pd.read_csv('02_load.TXT', sep="\t", header=0)
but in a loop since I have many files.