I have a folder full of .txt files; I'd like to assign the data in the files to arrays (all of which happen to have length 6x9 in the example below, but obviously these dimensions are not so important); and I'd like the array names to be the ones given by the .txt file name.
I can do what seem to be the first necessary steps like ...
x=glob.glob('*.txt')
y=np.empty_like(x)
for i in range(len(x)):
y[i]=x[i].rstrip('.txt')
z=np.empty((len(x),6,9))
for i in range(len(x)):
z[i] = np.loadtxt(x[i], delimiter = ',')
... then I would like to do something like
for i in range(len(z)):
y[i] = z[i]
but I get an error: ValueError: cannot set an array element with a sequence
.
How can I get around this? I need the arrays to have names in order to resume analysis on them. Evaluating the arrays every time I want them takes too much time.
Any help is appreciated,
Thanks!