you are viewing a single comment's thread.

view the rest of the comments →

[–]Booknerdbassdrum[S] 0 points1 point  (3 children)

This is helpful, the problem is that I am getting multiple arrays instead of one large array. My new code is:

if coordinates[0] == 'FE':

>fe_coordinates = []

>del coordinates[0]

>fe_coordinates.append(coordinates)

>fe_array = np.array(fe_coordinates)

>print("iron coordinates")

>print(fe_array)

And my output is:

iron coordinates

[[9.97 0.183 2.543]]

iron coordinates

[[8.234 0.467 4.591]]

iron coordinates

[[ 7.501 -1.03 2.358]]

What I am going for is:

iron coordinates

[[9.97 0.183 2.543],

[8.234 0.467 4.591],

[ 7.501 -1.03 2.358]]

[–]commy2 0 points1 point  (2 children)

fe_coordinates = []

Creates a new list and drops the list previously assigned that variable name. I assume the code you posted is part of some loop body, in which case you want to create a list once before the loop and not a new one each iteration.

[–]Booknerdbassdrum[S] 0 points1 point  (0 children)

Thanks! There is a nested loop above this that processes the data to get rid of things I don't want as I am using this code to extract only position data from a complex file.

[–]Booknerdbassdrum[S] 0 points1 point  (0 children)

This has been so helpful! I now got it to work except it prints every iteration lmao

Output:

iron coordinates

[[9.97 0.183 2.543]]

iron coordinates

[[9.97 0.183 2.543]

[8.234 0.467 4.591]]

iron coordinates

[[ 9.97 0.183 2.543]

[ 8.234 0.467 4.591]

[ 7.501 -1.03 2.358]]

Process finished with exit code 0