Hello,
I am trying to write a python code which will be used in GIS environment to select certain records based on the values of a field. I am using Win XP SP3 with Python 2.5.1
Before switching to Python 2.5.1, this VB code section was working in Python 2.4 Ever since the upgrade, VB code does not work.
Basically what I need is for the cursor to go to each record and see if the Address field starts with "LATLONG****" if it does start with that, then write to the Geocode Step "Step2" if not, then write "Step1"
I have tried "LIKE" but python does not like it. If I do it equals to specific LAt and LONG, it works, but there are million pairs of Lat and Long in the city.
Any help is appreciated.
THIS IS THE CODE THAT STOPPED WORKING::::
# Process: Calculate Field...
#gp.CalculateField_management(CFS_Geocode_step1__2_, "GEOCODE_STEP", "Step", "VB", "Dim Step as string\\nIf [Address] LIKE \"LATLONG*\" Then\\nStep = \"STEP2\"\\nElse\\nStep = \"STEP1\"\\nEnd If")
THIS IS THE CODE THAT I AM TRYING TO MAKE IT WORK::::
# Create search cursor for feature class for geocode STEP
rowsearch = gp.searchcursor("C:\\LRMS_ArcMap\\CFS_copy.mdb\\CFS_Geocode_step1","","","Address","")
row = rowsearch.Next()
# Create update cursor for feature class for geocode STEP
path = "C:\\LRMS_ArcMap\\CFS_copy.mdb\\CFS_Geocode_step1"
rows = gp.UpdateCursor(path)
row = rows.Next()
# Update the field Geocode Step based on the value in the field Address
while row:
if row.Getvalue("Address")LIKE'"LATLONG%"':
row.SetValue("GEOCODE_STEP","STEP2")
else :
row.SetValue("GEOCODE_STEP","STEP1")
rows.UpdateRow(row)
row = rows.Next()
print gp.GetMessages()
I am trying to write a python code which will be used in GIS environment to select certain records based on the values of a field. I am using Win XP SP3 with Python 2.5.1
Before switching to Python 2.5.1, this VB code section was working in Python 2.4 Ever since the upgrade, VB code does not work.
Basically what I need is for the cursor to go to each record and see if the Address field starts with "LATLONG****" if it does start with that, then write to the Geocode Step "Step2" if not, then write "Step1"
I have tried "LIKE" but python does not like it. If I do it equals to specific LAt and LONG, it works, but there are million pairs of Lat and Long in the city.
Any help is appreciated.
THIS IS THE CODE THAT STOPPED WORKING::::
# Process: Calculate Field...
#gp.CalculateField_management(CFS_Geocode_step1__2_, "GEOCODE_STEP", "Step", "VB", "Dim Step as string\\nIf [Address] LIKE \"LATLONG*\" Then\\nStep = \"STEP2\"\\nElse\\nStep = \"STEP1\"\\nEnd If")
THIS IS THE CODE THAT I AM TRYING TO MAKE IT WORK::::
# Create search cursor for feature class for geocode STEP
rowsearch = gp.searchcursor("C:\\LRMS_ArcMap\\CFS_copy.mdb\\CFS_Geocode_step1","","","Address","")
row = rowsearch.Next()
# Create update cursor for feature class for geocode STEP
path = "C:\\LRMS_ArcMap\\CFS_copy.mdb\\CFS_Geocode_step1"
rows = gp.UpdateCursor(path)
row = rows.Next()
# Update the field Geocode Step based on the value in the field Address
while row:
if row.Getvalue("Address")LIKE'"LATLONG%"':
row.SetValue("GEOCODE_STEP","STEP2")
else :
row.SetValue("GEOCODE_STEP","STEP1")
rows.UpdateRow(row)
row = rows.Next()
print gp.GetMessages()