this question or answer is not directly related to gis. but i have write sth. which will solve your problem. in python, you can make lots of way out for your problem as this example code. you can get results with another way which changes to your standpoint.
i have assumed that your locations are all in polyline.txt file.
file = open("polyline.txt", 'r')
FPoint = [] # Start Points Array
SPoint = [] # End Points Array
finalArray = [] # Final Array with Start and End Points
for line in file:
ln = line.rstrip().split(' ')
if len(ln) > 2:
if ln[0] == '0':
fPoint = [ln[1],ln[2]]
print 'Start Point', 'X:', ln[1], 'Y:', ln[2]
FPoint.append(fPoint)
else:
sPoint = [ln[1],ln[2]]
print 'End Point', 'X:', ln[1], 'Y:', ln[2]
SPoint.append(sPoint)
# Appending Last Array
for a in range(len(FPoint)):
finalArray.append([[FPoint[a][0], FPoint[a][1]],[SPoint[a][0], SPoint[a][1]]])
print finalArray
in last array, you can get line from something like this scheme :
[['Start Point 1', 'End Point 1'], ['Start Point 2', 'End Point 2']]
End the result:
Start Point X: 464736.164805 Y: 260940.098387
End Point X: 464707.179968 Y: 260900.098387
Start Point X: 464728.067242 Y: 260945.96605
End Point X: 464699.082405 Y: 260905.96605
Start Point X: 464719.969679 Y: 260951.833714
End Point X: 464690.984842 Y: 260911.833714
[[['464736.164805', '260940.098387'], ['464707.179968', '260900.098387']],
[['464728.067242', '260945.96605'], ['464699.082405', '260905.96605']],
[['464719.969679', '260951.833714'], ['464690.984842', '260911.833714']]]
i hope it helps you...