I'm writing a standalone Python script to use for labeling ArcMap 10.7 data. (Want to avoid label expressions for portability, etc). I'm attempting to use ID attribute to label based on ADMIN_ORG attribute data.
I have found from SO, that nested 'with' statements are better for this than nested 'for' statements. I tried to replicated the answers from this post ArcPy nested loop problem still having issues....
The script currently DOES print the data from the ID column as expected but errors at the end at
"for label in sc_label:" Runtime Error: A column was specified that does not exist. But the column absolutely does and was recognized in earlier attempts. What am I missing?
def newlabel(): fields = ['ID', 'ADMIN_ORG'] label = fields region = fields with arcpy.da.SearchCursor(fc, region) as sc_region: for region in sc_region: with arcpy.da.SearchCursor(fc, label) as sc_label: for label in sc_label:#errors here but still prints the attribute data print str(label)