# write Value to Table # search cursor scurs = arcpy.SearchCursor(infc) # update cursor ucurs = arcpy.UpdateCursor(tbl) for scur in scurs: newRow = scur.getValue("ID") while newRow <> 0: for ucur in ucurs: ucur.Value = scur.getValue("Value") # update row ucurs.updateRow(ucur)
Solved! Go to Solution.
table = "Basins.dbf" fc = "Watersheds.shp" fcDict = {} rows = arcpy.SearchCursor(fc, "", "", "", "ID A") for row in rows: fcDict[row.ID] = row.Value del rows, row x = 0 rows = arcpy.UpdateCursor(table, "", "", "", "ID A") for row in rows: if row.ID == sorted(fcDict): row.Value = fcDict[row.ID] rows.updateRow(row) print "Successfully updated row" x += 1 del rows, row table = "Basins.dbf" fc = "Watersheds.shp" arcpy.MakeTableView_management(table, "Basins_view") arcpy.AddJoin_management("Basins_view", "ID", fc, "ID") arcpy.CalculateField_management("Basins_view", "basins.Value", "[watersheds.Value]")table = "Airports_Info"
fc = "Airports"
fcDict = {}
rows = arcpy.SearchCursor(fc, "", "", "", "OBJECTID A")
for row in rows:
fcDict[row.OBJECTID] = row.Name
del rows, row
x = 0
rows = arcpy.UpdateCursor(table, "", "", "", "ID A")
for row in rows:
if row.ID == fcDict.keys():
row.Name = fcDict[row.ID]
rows.updateRow(row)
print "Successfully updated row"
x += 1
del rows, row
fcDict = {}
rows = arcpy.SearchCursor(infc,"","","","ID")
for row in rows:
fcDict[row.ID] = row.Value
del rows, row
x = 0
rows = arcpy.UpdateCursor(tbl,"","","","ID")
for row in rows:
if row.ID == fcDict.keys():
row.Value = fcDict[row.ID]
rows.updateRow(row)
x += 1
del rows, row
rows = arcpy.SearchCursor(infc,"","","","ID A") rows = arcpy.UpdateCursor(tbl,"","","","ID A")
table = "Basins.dbf" fc = "Watersheds.shp" fcDict = {} rows = arcpy.SearchCursor(fc, "", "", "", "ID A") for row in rows: fcDict[row.ID] = row.Value del rows, row x = 0 rows = arcpy.UpdateCursor(table, "", "", "", "ID A") for row in rows: if row.ID == sorted(fcDict): row.Value = fcDict[row.ID] rows.updateRow(row) print "Successfully updated row" x += 1 del rows, row table = "Basins.dbf" fc = "Watersheds.shp" arcpy.MakeTableView_management(table, "Basins_view") arcpy.AddJoin_management("Basins_view", "ID", fc, "ID") arcpy.CalculateField_management("Basins_view", "basins.Value", "[watersheds.Value]")# Import arcpy module
import arcpy
from arcpy import env
arcpy.env.overwriteOutput = True
dictionary = {'C':'INSERT1','Ca':'Coarse-Competent','D':'INSERT2' ,'E':'Fine-Competent','Ec':'Coarse-Competent',
'E-Ep':'INSERT3','Ep':'Coarse-Competent','gb':'Crystalline','gr':'INSERT4','grCz':'INSERT5','grCz?':'INSERT6','gr-m':'Crystalline','grMz':'Crystalline', 'grMz?':'Crystalline'}
Input_Geology_Feature_Class = arcpy.GetParameterAsText(0)
searchCursor = arcpy.SearchCursor(Input_Geology_Feature_Class,"","","PTYPE","")
arcpy.AddMessage("Adding Geology Class Field...")
arcpy.AddField_management(Input_Geology_Feature_Class, "Geology_Class","TEXT")
arcpy.AddMessage("Populating Geology Class Field, Please Wait...")
geology = arcpy.UpdateCursor(Input_Geology_Feature_Class,["PTYPE", "Geology_Class"])
for row in geology:
row[0] = dictionary(row[1])
geology.updateRow([row])
del row, geology