import arcpy lutTbl = r"Database Servers\CLINTONCOOPER_SQLEXPRESS.gds\VOTERS_20133 (VERSION:dbo.DEFAULT)\VOTERS_20133.DBO.frequency" mainTbl = r"Database Servers\CLINTONCOOPER_SQLEXPRESS.gds\VOTERS_20133 (VERSION:dbo.DEFAULT)\VOTERS_20133.DBO.OHIO_VOTERS_GEOCODE_OCT142013_small" lutDict = dict([(r.FULL_ADDRESS, (r.FREQUENCY)) for r in arcpy.da.SearchCursor(lutTbl, ["FULL_ADDRESS","FREQUENCY"]) updateRows = arcpy.da.UpdateCursor(mainTbl, ["FULL_ADDRESS","FREQUENCY"]) for updateRow in updateRows: nameValue = updateRow.FULL_ADDRSS if nameValue in lutDict: updateRow[1] = lutDict[nameValue][0] #Address else: updateRows.updateRow(updateRow) del updateRow, updateRows
Solved! Go to Solution.
import arcpy lutTbl = r"Database Servers\CLINTONCOOPER_SQLEXPRESS.gds\VOTERS_20133 (VERSION:dbo.DEFAULT)\VOTERS_20133.DBO.frequency" mainTbl = r"Database Servers\CLINTONCOOPER_SQLEXPRESS.gds\VOTERS_20133 (VERSION:dbo.DEFAULT)\VOTERS_20133.DBO.OHIO_VOTERS_GEOCODE_OCT142013_small" lutDict = {r[0]: r[1] for r in arcpy.da.SearchCursor(lutTbl, ["FULL_ADDRESS","FREQUENCY"])} with arcpy.da.UpdateCursor(mainTbl, ["FULL_ADDRESS","FREQUENCY"]) as updateRows: for updateRow in updateRows: nameValue = updateRow[0] if nameValue in lutDict: updateRow[1] = lutDict[nameValue][0] #Address updateRows.updateRow(updateRow)
import arcpy lutTbl = r"Database Servers\CLINTONCOOPER_SQLEXPRESS.gds\VOTERS_20133 (VERSION:dbo.DEFAULT)\VOTERS_20133.DBO.frequency" mainTbl = r"Database Servers\CLINTONCOOPER_SQLEXPRESS.gds\VOTERS_20133 (VERSION:dbo.DEFAULT)\VOTERS_20133.DBO.OHIO_VOTERS_GEOCODE_OCT142013_small" lutDict = {r[0]: r[1] for r in arcpy.da.SearchCursor(lutTbl, ["FULL_ADDRESS","FREQUENCY"])} with arcpy.da.UpdateCursor(mainTbl, ["FULL_ADDRESS","FREQUENCY"]) as updateRows: for updateRow in updateRows: nameValue = updateRow[0] if nameValue in lutDict: updateRow[1] = lutDict[nameValue][0] #Address updateRows.updateRow(updateRow)
updateRow[1] = lutDict[nameValue][0]
updateRow[1] = lutDict[nameValue]
You're mixing up arcpy.SearchCursor and arcpy.da.SearchCursor, among other issues (missing closing parens, indentation).import arcpy lutTbl = r"Database Servers\CLINTONCOOPER_SQLEXPRESS.gds\VOTERS_20133 (VERSION:dbo.DEFAULT)\VOTERS_20133.DBO.frequency" mainTbl = r"Database Servers\CLINTONCOOPER_SQLEXPRESS.gds\VOTERS_20133 (VERSION:dbo.DEFAULT)\VOTERS_20133.DBO.OHIO_VOTERS_GEOCODE_OCT142013_small" lutDict = {r[0]: r[1] for r in arcpy.da.SearchCursor(lutTbl, ["FULL_ADDRESS","FREQUENCY"])} with arcpy.da.UpdateCursor(mainTbl, ["FULL_ADDRESS","FREQUENCY"]) as updateRows: for updateRow in updateRows: nameValue = updateRow[0] if nameValue in lutDict: updateRow[1] = lutDict[nameValue][0] #Address updateRows.updateRow(updateRow)