<?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: how to define the field contents to be copied in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-define-the-field-contents-to-be-copied/m-p/542287#M42325</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Provide S with in single quotes in the expression argument.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.CalculateField_management("outputS.shp", "All", "'S'","PYTHON_9.3")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Siva&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 29 May 2012 05:02:14 GMT</pubDate>
    <dc:creator>GSKTRYG</dc:creator>
    <dc:date>2012-05-29T05:02:14Z</dc:date>
    <item>
      <title>how to define the field contents to be copied</title>
      <link>https://community.esri.com/t5/python-questions/how-to-define-the-field-contents-to-be-copied/m-p/542286#M42324</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;System ArcGIS 9.3&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Problem:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I created a new field "All" and want to copy "S" (Text) to it based on the selected rows.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;However, a warning showed, saying "S" is not defined.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Please kindly advise any modification to the code below.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;##Script Name: calculate sum ##Description: calculate sum&amp;nbsp; ##Created By: Elaine Kuo ##Date: 26/05/2012&amp;nbsp;&amp;nbsp; #Import standard library modules import arcgisscripting import os&amp;nbsp; #Create the Geoprocessor object gp = arcgisscripting.create(9.3)&amp;nbsp; #Set the workspace. gp.Workspace= "H:/temp/test"&amp;nbsp; #Set the workspace. List all of the feature classes in the dataset outWorkspace= "H:/temp"&amp;nbsp; #Get a list of the featureclasses in the input folder fcs = gp.ListFeatureClasses()&amp;nbsp; # Create a value table that will hold all of the input features to Merge. vt = gp.createobject("ValueTable")&amp;nbsp;&amp;nbsp; # Loop through every item in the list that was just generated for fc in fcs:&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; # Break out the name, no path or extension, using the describe object. &amp;nbsp;&amp;nbsp;&amp;nbsp; desc = gp.describe(fc) &amp;nbsp;&amp;nbsp;&amp;nbsp; featureName = desc.name&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; # Add a field to this shapefile, of type LONG &amp;nbsp;&amp;nbsp;&amp;nbsp; gp.AddField (fc, "All", "Text", 6,6)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; # Populate the input value table with feature classes. &amp;nbsp;&amp;nbsp;&amp;nbsp; vt.AddRow(fc) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; #&amp;nbsp;&amp;nbsp; Get a list of the fields in the featureclass &amp;nbsp;&amp;nbsp;&amp;nbsp; fields = gp.ListFields(fc, "C*", "String") &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; # Loop through every item in the list that was just generated&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; for field in fields:&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.toolbox = "Data Management" &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.addMessage(type(field))&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Select records to be copied (C*, i.e. C7658) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Make temporary featureclasses &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; query = "\"%s\" = 'S'" % field.Name &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.Select_analysis(fc,("outputS.shp"),query)&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # copy values in existing fields to the new field &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;&amp;nbsp; gp.CalculateField_management("outputS.shp", "All", "S","PYTHON_9.3")&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; #Validate the new feature class name for the output workspace. &amp;nbsp;&amp;nbsp;&amp;nbsp; OutFeatureClass = outWorkspace + os.sep + gp.ValidateTableName(fc,outWorkspace)&amp;nbsp; gp.AddMessage(gp.GetMessages()) print gp.GetMessages()&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 27 May 2012 23:11:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-define-the-field-contents-to-be-copied/m-p/542286#M42324</guid>
      <dc:creator>ElaineKuo</dc:creator>
      <dc:date>2012-05-27T23:11:47Z</dc:date>
    </item>
    <item>
      <title>Re: how to define the field contents to be copied</title>
      <link>https://community.esri.com/t5/python-questions/how-to-define-the-field-contents-to-be-copied/m-p/542287#M42325</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Provide S with in single quotes in the expression argument.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.CalculateField_management("outputS.shp", "All", "'S'","PYTHON_9.3")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Siva&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 May 2012 05:02:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-define-the-field-contents-to-be-copied/m-p/542287#M42325</guid>
      <dc:creator>GSKTRYG</dc:creator>
      <dc:date>2012-05-29T05:02:14Z</dc:date>
    </item>
  </channel>
</rss>

