AnsweredAssumed Answered

Why is Search Cursor not honoring layer Selection?

Question asked by RichardH522 on Apr 4, 2019
Latest reply on Jun 13, 2019 by bixb0012

In an ArcPro python script I have created a feature layers from a GDB feature class and made a selection.  

field_values = {}
# Field names are identical between the source and the target
row_cnt = int(arcpy.GetCount_management(selected_layer).getOutput(0))
cnt = 0
with da.SearchCursor(selected_layer, update_fields) as _cursor:
    for _row in _cursor:
       update_values = _row[:-1]
       _geo = _row[-1]
       for i in range(len(update_values)):
          fld = update_fields[i]
          if fld not in field_values:
             field_values[fld] = [update_values[i]]

# add this row to the excel table for visual comparison of source data to the final row
cnt += 1

The row count of the selected layer is 21, but when I increase the cnt variable by one each time through the cursor, the total number of lines is 167.


Has anyone experienced this issue with ArcPy for Pro?  Do layer selections in Pro not work with da.Cursors?


I was thinking that a naming conflict between the feature class and the layer could be happening so I appended "_lyr" to the end of the layer name.