1

I have a workflow that ingests a feature class, loops through with an update cursor, and then appends to an SDE table. The output feature order does not match the input order. I suspect parallel batching may be happening, but I'm curious if anyone knows how it's working under the hood.

Here's a mockup of what the output data looks like:

output example

The cursor loops through the data and assigns an ID in sequential order. Note that initially, the assigned IDs match the ObjectID. However, after a certain point it switches to alternating between a later ID number and the original number. Sometimes, it might even double up on the "second list" of numbers e.g. Feature_ID: 1, 2, 3, 7, 4, 8, 9, 5, 10, 6

Here's the code (stripped of non-necessary info):

intermediate_fc = "memory/int_fc"
arcpy.management.CopyFeatures(in_fc, intermediate_fc)
feature_num = get_feature_num(eng, proj_code, True)
fields = ["feature_id"]
with arcpy.da.UpdateCursor(intermediate_fc, fields) as cursor:
 
 for row in cursor:
 feature_num += 1
 row[0] = str(feature_num).zfill(6)
 cursor.updateRow(row)
arcpy.management.Append(intermediate_fc, TARGET_FC, schema_type='NO_TEST')
PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Oct 3, 2024 at 21:04
1
  • Added the sql_clause and it unfortunately is still having the same behavior Commented Oct 4, 2024 at 15:10

1 Answer 1

0

I suspect arcpy.management.Append may be sending data in batches (or otherwise async) under the hood, and the target geodatabase is just assigning new OBJECTID values in whatever order the new rows arrive. Since the result is still sorta sequential but not a strict pattern, I wonder if row differences (e.g., geometry vertex count) are contributing to this.

If keeping your original order were important, replacing the Append with a SearchCursor & InsertCursor combo, like here , could work.

PS, I also see a similar issue is mentioned here .

answered Oct 4, 2024 at 21:30

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.