I have a feature class which I've been using a relate to compare duplicate field values and was thinking of a way to eliminate the manual process of checking these duplicate values and making a decision as to which records to keep. There are several parameters which determine which record is kept vs. which one is discarded. For now I'd like to flag which records are kept so I can do some spot checking on the attributes.
I have some mock data below to show the desired results in a "Flagged" field. The conditions would involve first using a where clause to prompt the cursor to scan the "ID" field where ID = X. For this selection compare fieldB records, if they are equal values and one of them does not contain the letter 'C' compare fieldA records and flag the one with the higheest numeric value unless there is a null in one of the fieldA records. If one of these records contains a null value, compare the records in fieldC and flag the greatest value.
Feature class records:
fieldA fieldB fieldC Flagged ID
1 ABC 4 X
2 AB 5 X
3 A 6 X
1 EFG 4 Y
2 EF 5 Y
3 E 6 Y
Desired result in "Flagged" field:
fieldA fieldb fieldC Flagged ID
1 ABC 4 X
2 AB 5 X
3 A 6 1X X
1 EFG 4 Y
2 EF 5 Y
3 E 6 1Y Y
if/elif/else
statements, as well as making use of python lists and themax ()
method.