I'm creating a dictionary from featureclasses - emassDict = {u'1': [2009621.0, 2009622.0, 2009624.0, 2009623.0, 2009625.0, 2009626.0, 2009627.0]}{u'2': [2009633.0]}{u'3': [2009632.0, 2009631.0, 2009630.0, 2009629.0, 2009628.0]}{u'4': [2009617.0, 2009611.0, 2009610.0, 2009614.0, 2009620.0, 2009612.0, 2009616.0, 2009615.0, 2009613.0, 2009618.0, 2009607.0, 2009605.0, 2009619.0, 2009609.0, 2009606.0, 2009608.0]}{u'5': [2009604.0, 2009601.0, 2009600.0, 2009603.0, 2009602.0]}{u'6': [2009100.0]}{u'7': [2009009.0]}{u'8': [2009004.0, 2009005.0, 2009007.0, 2009008.0, 2009001.0, 2009003.0, 2009002.0, 2009006.0]}{u'9': [2009500.0]} In this same script I want to update one of the fields "iField" with the values from the dictionary - if the key matches the values in another field "eZoneName". The dictionary is being created, but "iField" is not being populated. I'm not receiving any error messages so it has to be in the logic, but I can't see it. Please help, the total script is here: eZones = r"C:\temp\NLF.gdb\NLF_EM_2009_Dissolve"
eZoneName = str("UniqueID")
iField = "All_EM_List"
eIncidents = r"C:\temp\NLF.gdb\NLF_EM_2009_Identity"
emNameField = ("E_MASS")
joinField = "Dissolve_FID"
arcpy.MakeFeatureLayer_management(eIncidents, "eIncidentsLayer")
with arcpy.da.UpdateCursor(eZones, (eZoneName, iField)) as zoneRows:
for zone in zoneRows:
eZoneNameString = zone[0]
queryString = '"' + eZoneName + '" = ' + "'" + eZoneNameString + "'"
arcpy.MakeFeatureLayer_management(eZones, "CurrenteZonesLayer", queryString)
try:
arcpy.SelectLayerByLocation_management("eIncidentsLayer", "CONTAINED_BY", "CurrenteZonesLayer")
emassDict = dict()
for row in arcpy.SearchCursor("eIncidentsLayer"):
emName = row.getValue(emNameField)
snName = row.getValue(joinField)
if snName in emassDict:
emassDict[snName].append(emName)
else:
emassDict[snName] = [emName]
print emassDict
if eZoneNameString == [snName]:
zone[1] = [emName]
zoneRows.updateRow(zone)
except arcpy.ExecuteError:
print(arcpy.GetMessages(0))
finally:
arcpy.Delete_management("CurrenteZonesLayer")
arcpy.Delete_management("eIncidentsLayer")
del zone, zoneRows
... View more