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
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
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
Solved! Go to Solution.
countycode = tuple(arcpy.da.SearchCursor("Countieslayer", "FIPS_TXT"))[0][0] urows = arcpy.da.UpdateCursor("Stewardship", "County") for urow in urows: urow[0] = countycode urows.updateRow(urow)
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 obj_id += 1 # 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) del srow, srows, urow, urows #Clean up cursor objects
srows = arcpy.SearchCursor("Countieslayer") for srow in srows: # assign a variable for the value of srow.getValue("FIPS_TXT) countycode = srow.FIPS_TXT # create the update cursor urows = arcpy.UpdateCursor("Stewardship") for urow in urows: urow.County = countycode urows.updateRow(urow)
countycode = tuple(arcpy.da.SearchCursor("Countieslayer", "FIPS_TXT"))[0][0] urows = arcpy.da.UpdateCursor("Stewardship", "County") for urow in urows: urow[0] = countycode urows.updateRow(urow)
countycode = tuple(arcpy.da.SearchCursor("Countieslayer", "FIPS_TXT"))[0][0]