KevinBellSLC

Field mapping for dummies?

Discussion created by KevinBellSLC on Aug 29, 2013
Latest reply on Aug 30, 2013 by Caleb1987
Hi all!  I don't think I'm smart enough to get this arcpy.fieldmapping thing...  Does the following code have any advantages/disadvantages compared to the fieldmapping?  I like this because it seems like a lower level solution.

    d = {}
    flds = ['pk1', 'origFld1', 'origFld2']
    with arcpy.da.SearchCursor(myTbl, flds) as c:
        for r in c:
            d[r[0]] = (r[1], r[2])
    
    flds = ['pk2', 'destFld1', 'destFld2']
    with arcpy.da.UpdateCursor('myFC', flds) as cc:
        for rr in cc:
            if d.has_key(rr[0]):
                rr[1] = d[rr[0]][0]
                rr[2] = d[rr[0]][1]
                rr[3] = d[rr[0]][2]
      
                cc.updateRow(rr)
            else:
                pass

Outcomes