I wrote code using the arcpy.searchCursor and arcpy.UpdateCursor but want to switch to arcpy.da.SearchCursor and arcpy.da.UpdateCursor. I tried to change it but I get an error message in the lines after the updatecursor. Does anybody can tell me what I am doing wrong? Thank you!
I changed from this
to this:
And I get this error message:
PYTHON ERRORS:
Traceback Info:
File "D:\ArcGISData\SARS\Python_10April2013\BoundaryReporting_26March2013_changes_july2013_added_domain_changed_again.py", line 226, in <module>
for row in rows:
Error Info:
<type 'exceptions.AttributeError'>: Object: Error in parsing arguments for AddMessage
For this part:
I changed from this
Code:
srows = arcpy.SearchCursor("Countieslayer", )
obj_id = 1
for srow in srows:
# assign a variable for the value of srow.getValue("FIPS_TXT)
countycode = srow.FIPS_TXT
# Get a collection of rows for the update cursor
# create the update cursor
urows = arcpy.UpdateCursor("Stewardship")
# cycle through the rows (in this case only 1)
# to actually update the row in the cursor
# with the values obtained from the search cursor
for urow in urows:
urow.County = countycode
urows.updateRow(urow)
obj_id += 1
Code:
with arcpy.da.SearchCursor("Countieslayer", ("FIPS_TXT")) as cursor:
obj_id = 1
countycode = ""
countycode2 = ""
for row in cursor:
# assign a variable for the value of srow.getValue("FIPS_TXT)
countycode = row[0]
# Get a collection of rows for the update cursor
# create the update cursor
with arcpy.da.UpdateCursor("Stewardship", ("County")) as cursor:
# cycle through the rows (in this case only 1)
# to actually update the row in the cursor
# with the values obtained from the search cursor
for row in cursor:
countycode2 = countycode
countycode2 = row[0]
cursor.updateRow(row)
obj_id += 1
PYTHON ERRORS:
Traceback Info:
File "D:\ArcGISData\SARS\Python_10April2013\BoundaryReporting_26March2013_changes_july2013_added_domain_changed_again.py", line 226, in <module>
for row in rows:
Error Info:
<type 'exceptions.AttributeError'>: Object: Error in parsing arguments for AddMessage
For this part:
Code:
rows = arcpy.SearchCursor("Stewardship")
obj_id = 1
for row in rows:
FFYtxt = row.getValue("FFY")
Countytxt = row.getValue("County")
arcpy.AddMessage(Countytxt)
rowsffycounty = arcpy.UpdateCursor("Stewardship")
for row in rowsffycounty:
row.FFYCounty = FFYtxt + "-" + Countytxt
#FFYCountytxt = row.FFYCounty
rowsffycounty.updateRow(row)
obj_id += 1