Bleroux

Compare Access Table to SDE Feature Class

Discussion created by Bleroux on Apr 23, 2012
Latest reply on Apr 25, 2012 by kimo
I am new to python so I am working through a comparison script that will let me know if there are any differences between an mdb and a feature class (FC). Both tables with contain roughly 500,000 records. When comparing it takes probably 30 seconds for each record to find a match. I find this method to be extremely slow and I still need to add another match field. Is there a better way to compare the tables?

Eventually my end result will:
Remove records from the FC that are no longer in the mdb table.
If the recor in the mdb is newer (based on comparing time stamp field) the FC record will be removed.
Any records not found or that have newer data than FC will be added to a table in my SDE database that is dynamically geocoded back to the FC.

# Import system modules
import arcpy, os

desc = arcpy.Describe 

# Local variables:

table = "D:/HOPOLICIES/Test.mdb/tblHOPolicies"
fc = "Database Connections\\ArcSDE.sde\\ArcSDE.A10713.HOPolicies_NW"

cField = "Policy_Number"

rows = arcpy.SearchCursor(table)
row = rows.next()
while row:
    tableValue = row.getValue(cField)
    
    rows2 = arcpy.SearchCursor(fc)
    row2 = rows2.next()
    
    while row2:
        
        fcValue = row2.getValue(cField)
        if tableValue == fcValue:
            print tableValue + " Match Found to " + fcValue
            break            
        row2 = rows2.next()
    row = rows.next()

Outcomes