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]]
else:
field_values[fld].append(update_values[i])
# add this row to the excel table for visual comparison of source data to the final row
test_rows.append(update_values)
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.
Outside of ArcGIS Pro means executed in a separate process from the Pro application, either a standalone script or even a script tool run from within Pro. If I ran code from within the interactive Python window, the selections would be honored, but that was about it.