AnsweredAssumed Answered

Update Cursor.

Question asked by rengarajpy on Oct 30, 2015
Latest reply on Nov 1, 2015 by Dan_Patterson

Hello,

 

Can any one suggest me to the following code is correct or not?

 

Note: I need to update GISID from HT_GISID.

 

Code:

workspace1 = r"D:\ADC\Tool\Mumbai\PGDB For Reference\MVVNL_MAHMUDABAD\MVVNL_MAHMUDABAD.mdb"
workspace2 = r"D:\ADC\Tool\Mumbai\PGDB For Reference\MVVNL_MAHMUDABAD\Output.mdb"

searchFeatures = os.path.join(workspace2, "LTOVerHead_DTGISID")
updateFeatures = os.path.join(workspace1, "SecOHElectricLineSegment")

with arcpy.da.UpdateCursor(updateFeatures, ["OBJECTID", "GISID"]) as cursor1:
    for row1 in cursor1:
        gisiddict={}
        with arcpy.da.SearchCursor(searchFeatures, ["TARGET_FID", "HT_GISID"]) as cursor:
            for row in cursor:
                gisiddict[row[0]] = row[1]
            del row, cursor
        oid = row1[0]
        if(gisiddict.has_key(oid)):
            row1[1] = gisiddict[oid]
        cursor1.updateRow(row1)
    del row1, cursor1

Regards,

Raj P

 

Message was edited by: Dan Patterson  Syntax Highlighting add to make code readable.  Tags added to make it useful for searches

Outcomes