I am running the following python code:
import arcpy
import polyline
import csv
import re
fc = "E:\\GoogleString\\CadastreCoordinates\\version1\\coordinates.gdb\\cadastre_wc_1"
csvfile = "E:\\GoogleString\\CadastreCoordinates\\version1\\WC\\output.csv"
cursor = arcpy.SearchCursor(fc)
coord_list = []
ltlong = []
final_strings=[]
for row in cursor:
co = row.getValue("coordinates")
sg = row.getValue("sg21key")
testa = re.sub('(,[^,]*),', r'\1 ', co)
testb = re.sub('[()]', '', testa)
test2 = testb.split(' ')
coord_list.append(test2)
coords = [map(float,a.split(',')) for a in test2]
ltlong.append([sg,coords])
for i in ltlong:
string=polyline.encode(i[1],5)
final_strings.append([i[0],string])
with open(csvfile, "w") as output:
writer = csv.writer(output, lineterminator='\n')
writer.writerows(final_strings)
On my sample fc I got the output that I wanted and my code runs successfully but when I run my whole fc it tells me that I can't convert string to float. But it is the same data just a sample. Please help don't know what to do anymore.
ERROR:
Traceback (most recent call last):
File "C:\Handri\Python\google_str3.py", line 20, in <module>
coords = [map(float,a.split(',')) for a in test2]
ValueError: could not convert string to float: