Dear stackoverflow users,
I'm struggling with figuring out the following problem:
I have a directory with multiple files such as
datasets/
    dataset1.txt
    dataset2.txt
    dataset3.txt
    dataset4.txt
    dataset5.txt
and to read out the files and assign their content to a variable that is their filename without the file type extension. To be explicit: The content of dataset1.txt should be saved to a variable dataset1, the content of dataset2.txt should be saved to the variable dataset2 and so on.
I know that I can iterate over the content of my folder with the following function:
for root, dirs, files in os.walk('.'):
print(files)
but at the end it should do something like the folling:
for root, dirs, files in os.walk('.'):
for file in files:
file.split('.')[0] = numpy.loadtxt(file) # here it should create e.g. a variable dataset1 and read content of dataset1 into it.
How is this possible?
Regards,
Jakob
 
     
    