AnsweredAssumed Answered

Using update cursor with dictionary keys/values fails

Question asked by jborgion Champion on Aug 28, 2019
Latest reply on Aug 29, 2019 by jborgion

I've used Richard Fairhurst's TurboCharging method on numerous occasions and today for some unknown reason I'm getting an error I've never seen:  


TypeError: 'int' object is not subscriptable  


and I'm not sure what I've done wrong:

fc = 'DeliveryData_2018'
updateFields = ['Zipcode','ClientCount']

edit = arcpy.da.Editor(ws)

with arcpy.da.UpdateCursor(fc,updateFields) as updateRows:
    for updateRow in updateRows:
       keyValue = updateRow[0]
       if keyValue in countDict2018:
           updateRow[1] = countDict2018[keyValue][0]

countDict2018 is in the form of:

{'84006': 3,'84009': 14,'84020': 37,...}


I need to check for the value in  line 12 as my zipcode polygons have a few zipcodes that I don't serve; without that, it chokes on a zipcode value in the polygon fc that does not appear in the dictionary.


(End of the day blues...)