Hello everyone,
The goal is to find all the records that were deleted comparing yesterday and today versions of the same feature class.
I am running a python script that uses cursors. With the curosr I am able to identigy the record that was deleted because it was in the featuer class yesterday but not today.
When I insert a new record using "arcpy.da.InsertCursor", "curAppend.insertRow( rowYesterday)", two fields SHAPE_length and SHAPE_Area are equal to 0. ArcCatalog does not show any shape information in the preview, but shows only attributes in the Table view. It looks like features were created witout spatial data, only attributes.
dsc = arcpy.Describe(Layer_DEFAULT) fields = dsc.fields # # List all field names except the OID field # fieldnames = [field.name for field in fields if field.name != dsc.OIDFieldName] curYesterday = arcpy.da.SearchCursor(Layer_DEFAULT, fieldnames) curToday = arcpy.da.SearchCursor(Layer_PREPROD, fieldnames) curAppend = arcpy.da.InsertCursor(Layer_D,fieldnames) for rowYesterday in curYesterday: # # layerID = layerID # datetimeVal = CRTDATE # layerID = rowYesterday[0] datetimeVal = rowYesterday[4] #print rowYesterday[1] #print rowYesterday[2] #print rowYesterday[3] #print rowYesterday[4] #print rowYesterday[5] #print rowYesterday[0] if datetimeVal is not None: whereClause = '"AGMID" = %s' % (layerID) srcToday = arcpy.da.SearchCursor(Layer_PREPROD, fieldnames, whereClause) count = 0 for rowToday in srcToday: if rowToday[4] == rowYesterday[4]: count = count + 1 if count == 0: print "Record for Delete :", layerID logging.info('Delete ' + whereClause) curAppend.insertRow( rowYesterday)
Why isn't this marked as the correct answer? I understand that hardcoding is not ideal but it solved the issue that shown here.
This thread is fairly old, so it is hard to say how it got marked as "Assumed Answered" instead of "Answered." That said, even if it was "Answered" Jose's final post would not be marked as the answer. Jose's final post explains what he did with the answer to get his script working, Jose didn't identify the root cause and solution, which was how the SHAPE token was being used with the cursor.