'Cannot find field' error with arcpy.da.SearchCursor

2202
11
03-29-2022 10:08 AM
DavidHeacock
New Contributor II

Hi there - I have some scripts I've been trying to use that I haven't run in several months. There have been updates to Pro/Arcpy since then and now they are throwing errors, so I'm trying to get to the bottom of all  them.

I'm getting the "Cannot find field 'PARCEL_ID'" error coming from the code:

 

 

with arcpy.da.SearchCursor(templayer3, ['PARCEL_ID', "Acres"]) as cursor:
                for row in cursor:

 

 

I've checked for any typos, exported versions of 'templayer3' throughout the script and 'PARCEL_ID' is in there correctly formatted, without aliases, etc. Are there alternative reasons why one might get the 'Cannot find field' error?

Thanks

0 Kudos
11 Replies
DavidHeacock
New Contributor II

Well today the cursor is working with the in_memory layer converted to a feature class. So I'll note that in other places in my script. Not sure if something changed with arcpy in any of the updates since the cursor used to work on an in_memory layer.  Thanks all.

0 Kudos
JuneS
by
New Contributor

Not sure if you ever figured it out, David, but I wanted to put this here in case anybody is having a similar issue...

I was using templates to create my empty feature class and when I tried to use an insert cursor it said the field was missing. I realized I needed to update my table template to accommodate the extra field I was adding. So make sure in your original creation of the feature class/table that you have actually made the field you are trying to insert your values into!

Not sure if this is what it was for you, but I hope you figured it out in the end! 🙂

0 Kudos