<?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 Calculate Field in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/calculate-field/m-p/487595#M38063</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am using ArcPy 10.2 CalculateField management to format a field from an existing field.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;e.g. from 123456789 to {12-3456-789}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It works good using attribute table, but it shows "syntax error" when using python scripting.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Anyone has any solution?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 07 Feb 2014 22:29:21 GMT</pubDate>
    <dc:creator>HollyZhang1</dc:creator>
    <dc:date>2014-02-07T22:29:21Z</dc:date>
    <item>
      <title>Calculate Field</title>
      <link>https://community.esri.com/t5/python-questions/calculate-field/m-p/487595#M38063</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am using ArcPy 10.2 CalculateField management to format a field from an existing field.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;e.g. from 123456789 to {12-3456-789}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It works good using attribute table, but it shows "syntax error" when using python scripting.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Anyone has any solution?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Feb 2014 22:29:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculate-field/m-p/487595#M38063</guid>
      <dc:creator>HollyZhang1</dc:creator>
      <dc:date>2014-02-07T22:29:21Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field</title>
      <link>https://community.esri.com/t5/python-questions/calculate-field/m-p/487596#M38064</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I am using ArcPy 10.2 CalculateField management to format a field from an existing field.&lt;BR /&gt;e.g. from 123456789 to {12-3456-789}&lt;BR /&gt;It works good using attribute table, but it shows "syntax error" when using python scripting.&lt;BR /&gt;Anyone has any solution?&lt;BR /&gt;Thanks.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;What does the calculation look like in the Python script?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Feb 2014 22:38:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculate-field/m-p/487596#M38064</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2014-02-07T22:38:41Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field</title>
      <link>https://community.esri.com/t5/python-questions/calculate-field/m-p/487597#M38065</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;What does the calculation look like in the Python script?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; in the Python script like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;"{"+!field![:2]+"-"+!field![2:6]+"-"+!field![6:]+"}" &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;it works good in attribute table!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;By the way, !field! is string.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Feb 2014 23:08:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculate-field/m-p/487597#M38065</guid>
      <dc:creator>HollyZhang1</dc:creator>
      <dc:date>2014-02-07T23:08:28Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field</title>
      <link>https://community.esri.com/t5/python-questions/calculate-field/m-p/487598#M38066</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;in the Python script like:&lt;BR /&gt;"{"+!field![:2]+"-"+!field![2:6]+"-"+!field![6:]+"}" &lt;BR /&gt;it works good in attribute table!&lt;BR /&gt;By the way, !field! is string.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This has to be quoted and fed in as an expression to the CalculateField_management tool.&amp;nbsp; I seriously hope you did not actually create a field in a table called field.&amp;nbsp; That is a keyword that will cause problems.&amp;nbsp; If it has another name in the table use that name.&amp;nbsp; Anyway, something like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;from arcpy import env&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# Set environment settings&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;env.workspace = "C:/data/airport.gdb"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# Set local variables&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;inFeatures = "parcels"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;fieldName = "IDValue"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;expression = '"{"+!IDValue![:2]+"-"+!IDValue![2:6]+"-"+!IDValue![6:]+"}"'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# Execute CalculateField &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.CalculateField_management(inFeatures, fieldName, expression, "PYTHON_9.3")&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 08 Feb 2014 01:35:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculate-field/m-p/487598#M38066</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2014-02-08T01:35:14Z</dc:date>
    </item>
  </channel>
</rss>

