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

Create a copy of an existing attribute table field

$
0
0
What I am attempting to do is create a copy of an attribute field in a feature class. I want the values of both fields to be exactly the same, but I want their titles to be different. I think I'm close but I am receiving errors, and cannot resolve them myself.

Code:

import arcpy, string, os, fileinput
from arcpy import env
env.workspace = "filepath/filepath.gdb"
env.overwriteOutput = True
fc = "FeatureClass"
verification = arcpy.Exists (fc)
print verification
del verification

arcpy.AddField_management (fc, "NewField", "TEXT", "", "", "", "", "", "", "")
cursor = arcpy.da.UpdateCursor (fc, "NewField")
for row in cursor:
  delimfield = arcpy.AddFieldDelimiters (fc, ["OldField"])
  row[0]
  cursor.UpdateRow(row)
del row
del cursor

I think my issue is here: "delimfield = arcpy.AddFieldDelimiters (fc, ["OldField"])" I'm not even sure this is the right tool for copying over the values from one field to the other. After running the script I receive the error listed below. Any ideas?

Code:

Runtime error
Traceback (most recent call last):
  File "<string>", line 22, in <module>
AttributeError: 'da.UpdateCursor' object has no attribute 'UpdateRow'


Viewing all articles
Browse latest Browse all 2485

Trending Articles