Feb-17-2020, 09:00 PM
Hello,
i am trying to read a text file to get a list of point coordinates from a texte file :
this is the text :
-48.9701217110874,5.67558617156734,0
-43.5855912406261,6.54875327488539,0
-51.1530394693826,-3.20161271216619,0
-45.6229811483682,-1.89186205718911,0
-37.0368379657407,5.23900261990832,0
-52.8993736760187,6.54875327488539,0
-56.5375699398439,-0.727639252765042,0
i called the file polyline.txt and this how i wrote the code :
The problem i have now is how to transform that list of strings into a list of float numbers
How to remove the z coordinates since its 0
and if you are still interested by the problem
how to compute the vectors from that list of coordinates knowing that if if AB are two consecutive points
the vector slope is (Yb-Ya)/(Xb-Xa)
thanks !!!!
i am trying to read a text file to get a list of point coordinates from a texte file :
this is the text :
-48.9701217110874,5.67558617156734,0
-43.5855912406261,6.54875327488539,0
-51.1530394693826,-3.20161271216619,0
-45.6229811483682,-1.89186205718911,0
-37.0368379657407,5.23900261990832,0
-52.8993736760187,6.54875327488539,0
-56.5375699398439,-0.727639252765042,0
i called the file polyline.txt and this how i wrote the code :
def ImportPointList(): f = open("polyline.txt") #open the text file lines = f.readlines() #read the line lines = [item.rstrip("\n") for item in lines] #divide the line in items pointList = list(lines) # create a list of items listLength = len(pointList) #tell me the number of items in the list print ("this is the new List",pointList,"composed of ",listLength,"items")
The problem i have now is how to transform that list of strings into a list of float numbers
How to remove the z coordinates since its 0
and if you are still interested by the problem

the vector slope is (Yb-Ya)/(Xb-Xa)
thanks !!!!