<?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: CalculateField error in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/calculatefield-error/m-p/1242886#M66322</link>
    <description>&lt;P&gt;Try importing your shapefile into a GDB as a table before preforming a Join or Relate. This can be completed many ways, such as from Catalog, right click on your GDB and select Import &amp;gt; Table(s). Then perfor the join on this table in your GDB not the CSV.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rachel Gomez&lt;/P&gt;</description>
    <pubDate>Wed, 21 Dec 2022 06:47:07 GMT</pubDate>
    <dc:creator>RachelGomez</dc:creator>
    <dc:date>2022-12-21T06:47:07Z</dc:date>
    <item>
      <title>CalculateField error</title>
      <link>https://community.esri.com/t5/python-questions/calculatefield-error/m-p/507391#M39876</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm getting an ExecuteError, error 000539, in the code below when Calculating the field. The error appears to be on the second instance of fc, fc.capitalize(), because when I take out the capitalize(), I get the same error but without the capitalized name. I can't figure out what the problem is. Any ideas? Thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# code&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt; fds = 'RawFramework'&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; newfield = 'CountyName'&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lstRawFCs = arcpy.ListFeatureClasses(None, 'All', fds)&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for fc in lstRawFCs:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddField_management(fc, newfield, 'TEXT', field_length = 25, field_alias = 'County Name')&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CalculateField_management(fc, newfield, fc.capitalize(), 'PYTHON_9.3')&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; except Exception as e:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print(e.message, e.__class__)&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P&gt;# sample error&lt;/P&gt;&lt;P&gt;(CalculateField).\n', &amp;lt;class 'arcgisscripting.ExecuteError'&amp;gt;)&lt;/P&gt;&lt;P&gt;('ERROR 000539: Error running expression: St_clair \nTraceback (most recent call last):\n&amp;nbsp; File "&amp;lt;expression&amp;gt;", line 1, in &amp;lt;module&amp;gt;\nNameError: name \'San_Diego\' is not defined\n\nFailed to execute (CalculateField).\n', &amp;lt;class 'arcgisscripting.ExecuteError'&amp;gt;)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Aug 2014 12:25:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculatefield-error/m-p/507391#M39876</guid>
      <dc:creator>Zeke</dc:creator>
      <dc:date>2014-08-27T12:25:23Z</dc:date>
    </item>
    <item>
      <title>Re: CalculateField error</title>
      <link>https://community.esri.com/t5/python-questions/calculatefield-error/m-p/507392#M39877</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Solved. Needed quotes around the value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;value = '"' + fc.capitalize() + '"'&lt;/P&gt;&lt;P&gt; arcpy.CalculateField_management(fc, newfield, value, 'PYTHON_9.3')&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Aug 2014 12:52:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculatefield-error/m-p/507392#M39877</guid>
      <dc:creator>Zeke</dc:creator>
      <dc:date>2014-08-27T12:52:27Z</dc:date>
    </item>
    <item>
      <title>Re: CalculateField error</title>
      <link>https://community.esri.com/t5/python-questions/calculatefield-error/m-p/507393#M39878</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;You are correct, string expressions in a python expression string need quotes.&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Single and double are interchangeable in Python (although the pairs must match). I try to use double as the "outside" quotes just for consistency as this seems to match what they do in the documentation and I find it easier to see.&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;I usually use string formatting of Python, SQL, and string expressions to make my code easier to read:&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14091707368418006 jive_text_macro" jivemacro_uid="_14091707368418006" modifiedtitle="true"&gt;
&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;value = "'{0}'".format(fc.capitalize())&lt;/P&gt;
&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;arcpy.CalculateField_management(fc, newfield, value, 'PYTHON_9.3')&lt;/P&gt;
&lt;/PRE&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;A href="https://community.esri.com/migration-blogpost/1070"&gt;Posting Code blocks in the new GeoNet&lt;/A&gt;‌&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Aug 2014 20:23:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculatefield-error/m-p/507393#M39878</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2014-08-27T20:23:05Z</dc:date>
    </item>
    <item>
      <title>Re: CalculateField error</title>
      <link>https://community.esri.com/t5/python-questions/calculatefield-error/m-p/1242886#M66322</link>
      <description>&lt;P&gt;Try importing your shapefile into a GDB as a table before preforming a Join or Relate. This can be completed many ways, such as from Catalog, right click on your GDB and select Import &amp;gt; Table(s). Then perfor the join on this table in your GDB not the CSV.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Rachel Gomez&lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2022 06:47:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculatefield-error/m-p/1242886#M66322</guid>
      <dc:creator>RachelGomez</dc:creator>
      <dc:date>2022-12-21T06:47:07Z</dc:date>
    </item>
  </channel>
</rss>

