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 <SPAN class="operator token">=</SPAN> <SPAN class="string token">'DeliveryData_2018'</SPAN>
updateFields <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">'Zipcode'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'ClientCount'</SPAN><SPAN class="punctuation token">]</SPAN>
edit <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>Editor<SPAN class="punctuation token">(</SPAN>ws<SPAN class="punctuation token">)</SPAN>
edit<SPAN class="punctuation token">.</SPAN>startEditing<SPAN class="punctuation token">(</SPAN><SPAN class="token boolean">False</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="token boolean">False</SPAN><SPAN class="punctuation token">)</SPAN>
edit<SPAN class="punctuation token">.</SPAN>startOperation<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">with</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>UpdateCursor<SPAN class="punctuation token">(</SPAN>fc<SPAN class="punctuation token">,</SPAN>updateFields<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">as</SPAN> updateRows<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">for</SPAN> updateRow <SPAN class="keyword token">in</SPAN> updateRows<SPAN class="punctuation token">:</SPAN>
keyValue <SPAN class="operator token">=</SPAN> updateRow<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN>
<SPAN class="keyword token">if</SPAN> keyValue <SPAN class="keyword token">in</SPAN> countDict2018<SPAN class="punctuation token">:</SPAN>
updateRow<SPAN class="punctuation token">[</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> countDict2018<SPAN class="punctuation token">[</SPAN>keyValue<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN>
updateRows<SPAN class="punctuation token">.</SPAN>updateRow<SPAN class="punctuation token">(</SPAN>updateRow<SPAN class="punctuation token">)</SPAN>
edit<SPAN class="punctuation token">.</SPAN>stopOperation<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
edit<SPAN class="punctuation token">.</SPAN>stopEditing<SPAN class="punctuation token">(</SPAN><SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="string token">'''
countDict2018 is in the form of:
{'84006': 3,'84009': 14,'84020': 37,...}
'''</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>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...)