Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Field mapping for dummies?

$
0
0
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.

Code:

    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


Viewing all articles
Browse latest Browse all 2485

Trending Articles