so I have a huge .txt-file with about 4 000 000 coordinates in the following format:
315987 5587999 718.80
315988 5587999 718.87
315989 5587999 719.03
315990 5587999 718.94
315991 5587999 718.97
...
So my task now is to read these coordinates in from this txt-file with a python script and store the data for each axis in a tuple (np-array) so I can use methods like np.flatten on the tuples.
For this tasks I found many answers on stackoverflow but somehow it was a little bit confusing and I couldnt manage to implement it how I wanted.
Here is my code:
def get_stl():
with open('test.txt') as f:
for line in f:
x, y, z = (float(a) for a in line.split())
X, Y = np.meshgrid(x, y, z)
Z = z;
return X, Y, Z
x, y, z = get_stl()
xyz = np.zeros(shape=(x.size, 3))
xyz[:, 0] = x.flatten()
xyz[:, 1] = y.flatten()
xyz[:, 2] = z.flatten()
So obviously z.flatten()
cant be executed because I didn't read in z as a np.array.
My question would be how to read in that large txt.file and especially the z-coordinate properly.
Thank you!
EDIT:
I don't want to use CSV because of its memory-usage