AnsweredAssumed Answered

'An expected field was not found or could not be retrieved properly' for arcpy.da.SearchCursor where clause

Question asked by gardta on Jan 23, 2018
Latest reply on May 31, 2019 by gisstaff_napacounty

 I am trying to add a where clause into a arcpy.da.SearchCursor statement, and I keep receiving a 'An expected Field was not found or could not be retrieved properly' error with this code:


where_expression = ' "FIELD2" = "CODE1" or "FIELD2" = "CODE2" '
search_feats = {f[0]:f[1] for f in arcpy.da.SearchCursor(table,["FIELD1","FIELD2","FIELD3"], where_expression)}

with arcpy.da.UpdateCursor(New_Table,["NT_FIELD_1","NT_FIELD_3"]) as upd_cur:
     for upd_row in upd_cur:
         upd_row[1] = search_feats.get(upd_row[0], 0)

del upd_cur

I believe this error is falling on the where clause, as if I exclude the clause from search_feats, the code runs without error. I have used a where clause successfully in this structure in the past, but not with a text field such as FIELD2 here. 


Any tips or suggestions would be much appreciated. I have tried many different variations of syntax with no luck yet. 

I have verified that the fields exist in the table, have been typed correctly, and do not have any locks.