Using Model Builder to search/delete matching records comparing two FCs

266
1
08-23-2022 10:38 AM
AmyMcCarthy
New Contributor II

Hello all!  I am fairly new to Model Builder (and a complete novice at Python) and I have been tasked with the following that would need to be run daily:

  • Select certain records for the past day from feature class #1
  • Compare the selection to feature class #2 based on a field called "event number".
  • *Tricky part* If the record already exists in feature class #2, delete it from feature class #2 (as it would be older data than the new record.  This would be identified by a matching "event number")
  • Append the selected records to feature class #2

Steps 1 and 4 are straightforward enough.  For 2 and 3, I'm guessing I'll need to do some sort of iteration and logical tool but I can't seem to find good examples to help generalize to what I'm trying to do.  Any help is much appreciated!

0 Kudos
1 Reply
RichardHowe
Occasional Contributor III

Amy,

I think all you need to do (in Model Builder) is perform a join from feature class #2 back to your selected records from feature class #1 (based on the "event number" field) and ensuring you tick the option to only retain matching records. Once they are joined you can delete all the records from the joined layer, and then remove the join and you will be left with all the records from feature class #2 that did not match. You can then append your selected records from feature class #1 to feature class #2.

I hope that makes some sense. Please let me know if not.

 

If you wanted to go down the python route then this could also be achieved via an update cursor.

0 Kudos