Arcpy

305
2
Jump to solution
04-01-2021 06:22 AM
Mick
by
New Contributor

Good day everybody.

I am currently working with a file geodatabase. I created an additional field in a feature class table and want to add all the information from another field located in the same feature class table. I guess I can do it with arcpy.da.UpdateCursor but not sure how to copy from one field to another. Could you please give any advice?

 

0 Kudos
1 Solution

Accepted Solutions
JeffK
by MVP Regular Contributor
MVP Regular Contributor

Hi Mick,

This is pretty straight forward.  Just include the two fields and set the source to the target:

with arcpy.da.UpdateCursor(fc, [sourceFld, targetFld]) as uCur:
    for row in Ucur:
        row[1] = row[0]
        uCur.updateRow(row)

 

View solution in original post

2 Replies
JeffK
by MVP Regular Contributor
MVP Regular Contributor

Hi Mick,

This is pretty straight forward.  Just include the two fields and set the source to the target:

with arcpy.da.UpdateCursor(fc, [sourceFld, targetFld]) as uCur:
    for row in Ucur:
        row[1] = row[0]
        uCur.updateRow(row)

 

BlakeTerhune
MVP Regular Contributor

You could also use Calculate Field to do something simple like this. You can even script creating the new field if you need!