#tcx converter to get a list of coordinates #12/2/2021 #we use a series of lat/lon values, with lat first #instantiate a list lat_container=[] lon_container=[] #open the tcx file and extract lat/lon very poorly #if there is a missing value in a pair, everything will break #this is very fragile with open("exercise_tcx_file.tcx")as cheese: for line in cheese: if "" in line or "" in line: line2=line.strip() if "" in line2: line3=line2.strip("") line3=line3.strip("") lat_container.append(line3) if "" in line2: line3=line2.strip("") line3=line3.strip("") lon_container.append(line3) #small test to see if there are any missing entries if len(lat_container) == len(lon_container): pass else: quit() #write a comma delimited text file for import into excel with open("tcx_convert_finish.txt","w") as cracker: cracker.write("PTnum,LAT,LON\n") for shift in range(0,len(lat_container)): cracker.write("%s,%s,%s\n" % (str(shift+1),lat_container[shift],lon_container[shift]))