I have a folder with n csv
files. They are accessed and read in a for loop like this:
#do stuff
for file in os.listdir(directoryPath):
if file.endswith(".csv"):
#do stuff
Outside of the for loop are a number of numpy
arrays initialized to zero. Each array has to carry a specific value located in the current csv
file.
My question: is it possible to use file
, which I assume is a string
, as an integer
, in order to fill my arrays for instance like this: array1[file]=numpy.genfromtxt(file,delimiter=',')[:,2]
?
I am afraid this very line does not work as file
cannot be treated like an integer
, so how would you deal with this? Thank you!