I spent more time on this issue than I am willing to admit. I have a function called:
def array_funct(filename):
...
data = np.array((array))
return data
which reads in .txt files from a folder and returns a numpy array.
The first row is a list of x coordinates and second row are the cooresponding y coordinates. Hence I use:
array_funct(filename)[:,0]
array_funct(filename)[:,1]
to access the x and y coordinates.
Now all I want to do is to create a for loop which would read in more than 1 file and store them in following way
for i in range(0,number_of_files):
array_funct(file[i])[:,0]
array_funct(file[i])[:,1]
Let's look at the x-lists which I get:
print(array_funct(file[0])[:,0])
[1,2,3,4]
print(array_funct(file[1])[:,0])
[2,4,6,8]
All I want is to take these two numpy like lists and create:
x_tot = [[1,2,3,4], [2,4,6,8]]
such that I can access the single lists element wise like:
x_tot[0] = [1,2,3,4]
Is that so hard? Should I stop using numpy array ? I would like to stay in numpy if possbile.
Also keep in mind that I made this example for just 2 files but it could be more. I just want to create a x_tot and y_tot for a variable amount of files I would read in. Such that:
x_tot = [[1,2,3],[2,3,4],[..],..]
x_tot = [[2,4,6],[4,6,8],[..],..]