sourceFCCur = arcpy.UpdateCursor(SourceFCPath) for sourceFCRow in sourceFCCur: targetFCCur = arcpy.UpdateCursor(TargetFCPath) for targetFCRow in targetFCCur: if targetFCRow.ID == sourceFCRow.ID: sourceFCDate = sourceFCRow.getValue('LASTMODIFIED') targetFCDate = targetFCRow.getValue('LASTMODIFIED') if sourceFCDate != targetFCDate: targetFCCur.updateRow(targetFCRow) del targetFCCur
Solved! Go to Solution.
targetFCCur = arcpy.UpdateCursor(TargetFCPath) for targetFCRow in targetFCCur: ... nothing with targetFCRow done here ... targetFCCur.updateRow(targetFCRow)
targetFCCur = arcpy.UpdateCursor(TargetFCPath) for targetFCRow in targetFCCur: ... nothing with targetFCRow done here ... targetFCCur.updateRow(targetFCRow)
import arcpy
source = "E:/test.mdb/src"
target = "E:/test.mdb/trg"
# cursor for sourceFC
s_rows = arcpy.SearchCursor(source)
# Dictionary for sourceFC´s fields
sDict = {}
# field names of sourceFC/targetFC, excluding Shape and OID
fList = [a.name for a in arcpy.ListFields(source) if a.name not in ("OBJECTID","Shape")]
# fill the sourceFC Dict(OIDs as keys) with dictionaries of its fieldnames/values
for s_row in s_rows:
sDict[s_row.OBJECTID] = dict((k,s_row.getValue(k)) for k in fList)
del s_row,s_rows
# update cursor for targetFC
t_rows = arcpy.UpdateCursor(target)
for t_row in t_rows:
# compare the current row's field with the corresponding one from the sourceFC-dict
# if values differ, update all target fields with sourceFC-dict´s values
if t_row.LASTMODIFIED != sDict[t_row.OBJECTID]["LASTMODIFIED"]:
for fName in fList:
t_row.setValue(fName, sDict[t_row.OBJECTID][fName])
t_rows.updateRow(t_row)
del t_row,t_rows
import arcpy
source = "E:/test.mdb/src"
target = "E:/test.mdb/trg"
# cursor for sourceFC
s_rows = arcpy.SearchCursor(source)
# Dictionary for sourceFCs fields
sDict = {}
# field names of sourceFC/targetFC, excluding Shape and OID
fList = [a.name for a in arcpy.ListFields(source) if a.name not in ("OBJECTID","Shape")]
# fill the sourceFC Dict(OID as key) with dictionaries of its fieldnames/values
for s_row in s_rows:
sDict[s_row.OBJECTID] = dict((k,s_row.getValue(k)) for k in fList)
# get point coordinates from the shape field and put them into the dict
s_pnt = s_row.Shape.getPart()
sDict[s_row.OBJECTID]["GEO"] = (s_pnt.X,s_pnt.Y)
del s_row,s_rows
print sDict
# update cursor for targetFC
t_rows = arcpy.UpdateCursor(target)
for t_row in t_rows:
# compare the current row's field with the corresponding one from the sourceFC-dict
# if values differ, update all target fields with sourceFC-dicts values
if t_row.LASTMODIFIED != sDict[t_row.OBJECTID]["LASTMODIFIED"]:
for fName in fList:
t_row.setValue(fName, sDict[t_row.OBJECTID][fName])
# replace point coordinates of shape field with values from the sourceFC-dict
t_pnt = arcpy.Point(sDict[t_row.OBJECTID]["GEO"][0],sDict[t_row.OBJECTID]["GEO"][1])
t_row.setValue("Shape", t_pnt)
t_rows.updateRow(t_row)
del t_row,t_rows