Essentially I am trying to get xy coordinates from a CSV. I have already converted the CSV to DBase and added 2 new double fields for LAT and LONG. But the original latitude and longitude values are in string type fields and contain "NA" values for some of the coordinates. I can remove the NA fields using a cursor because they are useless for plotting xy coordinates but I still am unable to copy the coordinate data from the string type columns to the new double type columns.
I have also tried the 2 following cursors as well
and regardless of what I do I receive the following error:
ExecuteError: ERROR 999999: Error executing function.
The value type is incompatible with the field type. [LAT]
Solved! Go to Solution.
Have you tried to explicitly convert the string to a double before writing it? For instance in your 2nd example:
row[1] = float(row[0])
Code formatting ... the Community Version - Esri Community
lat = "45.0"
float(lat)
45.0
You have to "float" text representations of numbers
Have you tried to explicitly convert the string to a double before writing it? For instance in your 2nd example:
row[1] = float(row[0])
I realize now that some of my data is incorrectly inputted (see below) and therefor I get this error : "ValueError: invalid literal for float(): 3.745.562.167". I can easily remove the incorrect data now, but the code will actually be used by people without gis experience and unfortunately these error will probably occur in future data. Is there a way to delete these error value rows within my cursor?
(still new to python, thanks for your help!)
Once I remove the weirdly formatted lat and long values it wont work using float but will work without so I have just done the following:
Thanks for your help!