I am currently writing a program that takes in the points of multiple circles, stored as tuples (x, y, z) in coor_input, from a csv file and processes them, each circle is identified by the z coordinate, I have managed this but with the use of multiple loops which I want to optimise for speed and neatness. I have tried using
for zs in coor_input:
if zs[2] not in z:
z.append(zs[2])
but that is almost exactly the same as the for loop. I am currently using the code below that works but I am looking for a way to condense it if at all possible?
coor_input is a list of coordinates stored as tuples ((1,2,3), (4,5,6)...)
#store each circle value of z coordinate
for ii in range(0, len(coor_input)):
if coor_input[ii][2] not in z:
z.append(coor_input[ii][2])
#each z identifies different circle
#go through each circle
for j in range(0, len(z)):
#reset coordinates
coordinates = []
#add coordinates to the circle of they have the
#same z coordinate as the circle
for f in range(0, len(coor_input)):
if coor_input[f][2] == z[j]:
#add coordinates of that circle
coordinates.append(coor_input[f])
#Process circle
There must be a way to optimise this but I have no clue, any help would be greatly appreciated
not in z? Do you want each z-coordinate to appear only once inz? If so, you should makezaset.