<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Create a copy of an existing attribute table field in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/create-a-copy-of-an-existing-attribute-table-field/m-p/391639#M30945</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You should be able to do something like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
for row in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp; row.setValue("NewField", row.getValue("OldField"))
&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.updateRow(row)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; 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.&amp;nbsp;&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt; &lt;PRE class="lia-code-sample line-numbers language-none"&gt;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:
&amp;nbsp;&amp;nbsp; delimfield = arcpy.AddFieldDelimiters (fc, ["OldField"])
&amp;nbsp;&amp;nbsp; row[0]
&amp;nbsp;&amp;nbsp; cursor.UpdateRow(row)
del row
del cursor&lt;/PRE&gt; &lt;BR /&gt; &lt;BR /&gt;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?&amp;nbsp;&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt; &lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color:&amp;quot;#FF0000&amp;quot;;"&gt;Runtime error 
Traceback (most recent call last):
&amp;nbsp; File "&amp;lt;string&amp;gt;", line 22, in &amp;lt;module&amp;gt;
AttributeError: 'da.UpdateCursor' object has no attribute 'UpdateRow'&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 17:57:01 GMT</pubDate>
    <dc:creator>AngelaHansen</dc:creator>
    <dc:date>2021-12-11T17:57:01Z</dc:date>
    <item>
      <title>Create a copy of an existing attribute table field</title>
      <link>https://community.esri.com/t5/python-questions/create-a-copy-of-an-existing-attribute-table-field/m-p/391638#M30944</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;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. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;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:
&amp;nbsp;&amp;nbsp; delimfield = arcpy.AddFieldDelimiters (fc, ["OldField"])
&amp;nbsp;&amp;nbsp; row[0]
&amp;nbsp;&amp;nbsp; cursor.UpdateRow(row)
del row
del cursor&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;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? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Runtime error 
Traceback (most recent call last):
&amp;nbsp; File "&amp;lt;string&amp;gt;", line 22, in &amp;lt;module&amp;gt;
AttributeError: 'da.UpdateCursor' object has no attribute 'UpdateRow'&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:25:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/create-a-copy-of-an-existing-attribute-table-field/m-p/391638#M30944</guid>
      <dc:creator>BrendanWhite1</dc:creator>
      <dc:date>2021-12-12T16:25:15Z</dc:date>
    </item>
    <item>
      <title>Re: Create a copy of an existing attribute table field</title>
      <link>https://community.esri.com/t5/python-questions/create-a-copy-of-an-existing-attribute-table-field/m-p/391639#M30945</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You should be able to do something like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
for row in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp; row.setValue("NewField", row.getValue("OldField"))
&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.updateRow(row)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; 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.&amp;nbsp;&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt; &lt;PRE class="lia-code-sample line-numbers language-none"&gt;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:
&amp;nbsp;&amp;nbsp; delimfield = arcpy.AddFieldDelimiters (fc, ["OldField"])
&amp;nbsp;&amp;nbsp; row[0]
&amp;nbsp;&amp;nbsp; cursor.UpdateRow(row)
del row
del cursor&lt;/PRE&gt; &lt;BR /&gt; &lt;BR /&gt;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?&amp;nbsp;&amp;nbsp; &lt;BR /&gt; &lt;BR /&gt; &lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color:&amp;quot;#FF0000&amp;quot;;"&gt;Runtime error 
Traceback (most recent call last):
&amp;nbsp; File "&amp;lt;string&amp;gt;", line 22, in &amp;lt;module&amp;gt;
AttributeError: 'da.UpdateCursor' object has no attribute 'UpdateRow'&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:57:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/create-a-copy-of-an-existing-attribute-table-field/m-p/391639#M30945</guid>
      <dc:creator>AngelaHansen</dc:creator>
      <dc:date>2021-12-11T17:57:01Z</dc:date>
    </item>
    <item>
      <title>Re: Create a copy of an existing attribute table field</title>
      <link>https://community.esri.com/t5/python-questions/create-a-copy-of-an-existing-attribute-table-field/m-p/391640#M30946</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The error states UpdateRow is invalid...it's because that's a method on a row object -- so I suspect you are trying to use this syntax instead which establishes a loop on the rows returned by the cursor:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;with arcpy.da.UpdateCursor(fc, fields) as cursor&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;See the samples listed at the webhelp here:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;UpdateCursor (arcpy.da)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Desktop » Geoprocessing » ArcPy » Data Access module&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//018w00000014000000"&gt;http://resources.arcgis.com/en/help/main/10.1/index.html#//018w00000014000000&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Looks like you need to establish opening a cursor, specifying 2 fields representing the 'old' and the 'new' (see example 1), then loop to capture the val from the old to write that in the new field, correct?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope that helps,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Wayne&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Aug 2013 16:44:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/create-a-copy-of-an-existing-attribute-table-field/m-p/391640#M30946</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2013-08-12T16:44:26Z</dc:date>
    </item>
    <item>
      <title>Re: Create a copy of an existing attribute table field</title>
      <link>https://community.esri.com/t5/python-questions/create-a-copy-of-an-existing-attribute-table-field/m-p/391641#M30947</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;So, something like this, but you have to test it yourself:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy from arcpy import env&amp;nbsp; env.overwriteOutput = True env.workspace = "filepath/filepath.gdb"&amp;nbsp; fc = "FeatureClass" fields = ('OldField', 'NewField')&amp;nbsp; #Add the new field arcpy.AddField_management (fc, "NewField", "TEXT")&amp;nbsp; # Create update cursor for feature class&amp;nbsp; # with arcpy.da.UpdateCursor(fc, fields) as cursor: &amp;nbsp;&amp;nbsp;&amp;nbsp; # For each row, read the OldField value (index position&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; #&amp;nbsp; of 0), and update NewField value (index position of 1) &amp;nbsp;&amp;nbsp;&amp;nbsp; # &amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[1] = row[0]&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Update the cursor with the updated list &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.updateRow(row)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;PS - Incidentally, you may just have a case-sensitivity error in:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;cursor.UpdateRow(row)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;...since 'UpdateRow' is not recognized, you may fix your own error with 'updateRow'.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I just noticed that.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 12 Aug 2013 16:59:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/create-a-copy-of-an-existing-attribute-table-field/m-p/391641#M30947</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2013-08-12T16:59:03Z</dc:date>
    </item>
    <item>
      <title>Re: Create a copy of an existing attribute table field</title>
      <link>https://community.esri.com/t5/python-questions/create-a-copy-of-an-existing-attribute-table-field/m-p/391642#M30948</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Taking Wayne's advice into consideration, I have changed the cursor as shown below.&amp;nbsp; However I am not getting any error, but the "NewField" is not updating to reflect the "OldField" values.&amp;nbsp; They are still null.&amp;nbsp; This says to me the script is just skipping the cursor.&amp;nbsp; Any suggestions?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy, string, os, fileinput
from arcpy import env
env.workspace = "filepath/file.gdb"
env.overwriteOutput = True
fc = "feature class"
verification = arcpy.Exists (fc)
print verification
del verification


arcpy.AddField_management (fc, "NewField", "TEXT", "", "", "", "", "", "", "")
fields&amp;nbsp; = ("OldField", "NewField")
with arcpy.da.UpdateCursor (fc, fields) as cursor:
&amp;nbsp;&amp;nbsp; for row in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[1] = row[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.updateRow(row)
del row
del cursor&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:57:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/create-a-copy-of-an-existing-attribute-table-field/m-p/391642#M30948</guid>
      <dc:creator>BrendanWhite1</dc:creator>
      <dc:date>2021-12-11T17:57:04Z</dc:date>
    </item>
    <item>
      <title>Re: Create a copy of an existing attribute table field</title>
      <link>https://community.esri.com/t5/python-questions/create-a-copy-of-an-existing-attribute-table-field/m-p/391643#M30949</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Working just fine for me as long as OldField actually exists in the FC.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Could change to this for help trouble shooting:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;with arcpy.da.UpdateCursor(fc, fields) as cursor:
&amp;nbsp;&amp;nbsp; for row in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[1] = "test"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.updateRow(row)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If this works, and codes all values in NewField to "test", then it is just not getting the correct input. Are you sure OldField is not nulls here as I get exactly the same in my new column.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;R_&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:25:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/create-a-copy-of-an-existing-attribute-table-field/m-p/391643#M30949</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2021-12-12T16:25:18Z</dc:date>
    </item>
    <item>
      <title>Re: Create a copy of an existing attribute table field</title>
      <link>https://community.esri.com/t5/python-questions/create-a-copy-of-an-existing-attribute-table-field/m-p/391644#M30950</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;So, something like this, but you have to test it yourself:&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
from arcpy import env

env.overwriteOutput = True
env.workspace = "filepath/filepath.gdb"

fc = "FeatureClass"
fields = ('OldField', 'NewField')

#Add the new field
arcpy.AddField_management (fc, "NewField", "TEXT")

# Create update cursor for feature class 
#
with arcpy.da.UpdateCursor(fc, fields) as cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp; # For each row, read the OldField value (index position 
&amp;nbsp;&amp;nbsp;&amp;nbsp; #&amp;nbsp; of 0), and update NewField value (index position of 1)
&amp;nbsp;&amp;nbsp;&amp;nbsp; #
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row[1] = row[0]

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Update the cursor with the updated list
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.updateRow(row)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;PS - Incidentally, you may just have a case-sensitivity error in:&lt;BR /&gt;cursor.UpdateRow(row)&lt;BR /&gt;&lt;BR /&gt;...since 'UpdateRow' is not recognized, you may fix your own error with 'updateRow'.&lt;BR /&gt;I just noticed that.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My problem was the capitalization, Wayne.&amp;nbsp; Thank you for pointing that out.&amp;nbsp; Being new to Python (programming in general) capitalization kills me.&amp;nbsp; Thank you everyone for the help.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:57:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/create-a-copy-of-an-existing-attribute-table-field/m-p/391644#M30950</guid>
      <dc:creator>BrendanWhite1</dc:creator>
      <dc:date>2021-12-11T17:57:07Z</dc:date>
    </item>
  </channel>
</rss>

