AnsweredAssumed Answered

delete duplicates records based on field

Question asked by 2CQuiker on Oct 13, 2016
Latest reply on Oct 18, 2016 by 2CQuiker

I need to be able to delete duplicate records but keep one only if it has a certain attribute in a certain field in a table. so i need to keep one of each "Acct" row but only if it has "01" in the Group _code. I need to be able to do this in arcpy python because i get this table weekly so i would like to schedule this task. Attached is a pic of the table i am working with.

 

I think i can iterate  the "group_code" field and append the value and "Acct" to a dictionary.

I have the following but i am not sure how to select and remove duplicates. I would appreciate some help with some code.

 

import arcpy  
from arcpy import env 
env.overwriteOutput = 1 
env.workspace = r"C:\GIS\LandValue.gdb" 
 
fc = "LandValue3" 
 
dict = {} 
 
with arcpy.da.SearchCursor(fc, ["Acct", "group_code"]) as cursor: 
    for row in cursor: 
        dict[row[0]] = row[1] 
 
del cursor

Attachments

Outcomes