I have a folder which contains numpy files. I need to create a numpy list where I will put all my numpy file names. For that, I use this code:
import os
a = open('C:\\Users\\user\\My_Test_Traces\\Traces.list_npy', "w")
for path, subdirs, files in os.walk(r'C:\\Users\\user\\CPA_test_1000_Tests\\test'):
for filename in files:
f = os.path.join(path, filename)
a.write(str(f) + os.linesep)
As a result, it gives me a list of my files and their paths like this:
C:\\Users\\user\\My_Test_Traces\\ Trace1_Pltx1
C:\\Users\\user\\My_Test_Traces\\ Trace2_Pltx2
C:\\Users\\user\\My_Test_Traces\\ Trace3_Pltx3
C:\\Users\\user\\My_Test_Traces\\ Trace4_Pltx4
however , I need only the files name, I don't need any spaces between lines:
Trace1_Pltx1
Trace2_Pltx2
Trace3_Pltx3
Trace4_Pltx4