<?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: Error 539 while running CalculateField to copy strings in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/error-539-while-running-calculatefield-to-copy/m-p/246908#M19123</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I now worked some hours on the problem. The Problem are Features (like Feature 52) with ". It seams as CalculateField uses " as string delimiter. It now it workes with those features, if I first substitute all " with ' (using find &amp;amp; replace in ArcMap). Is there a posibility to deal with the " using a script?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The script now causes errors at features with an line break within the textfield. Any ideas how to deal with them in the script? The new Error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Runtime error &amp;lt;class 'arcgisscripting.ExecuteError'&amp;gt;: 
ERROR 000539: Error running expression: "servitude de 'passage à pied' non aménagé sur parcelle 4259
 servitude de 'passage à pied' non aménagé" 
&amp;lt;type 'exceptions.SyntaxError'&amp;gt;: EOL while scanning string literal (&amp;lt;string&amp;gt;, line 1)
Failed to execute (CalculateField). &lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 12:17:15 GMT</pubDate>
    <dc:creator>BärbelHorat</dc:creator>
    <dc:date>2021-12-11T12:17:15Z</dc:date>
    <item>
      <title>Error 539 while running CalculateField to copy strings</title>
      <link>https://community.esri.com/t5/python-questions/error-539-while-running-calculatefield-to-copy/m-p/246904#M19119</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;I'm trying to copy all information from one string field to a new one in the same feature class. I am using this code: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
#Feature class:
Tab = r'\\Tako\gis\03_basisdaten\pronatura\ch\gisdata\pronatura_1.gdb\Schutzgebiete\parz_pn'
#Field:
orgField = "Bemerkungen"
#Length of Field:
Length = 1000


#Adding the new Field:
provField = orgField + "_prov"
AddField_management(Tab,provField,"TEXT", "", "", Length)

#Copy the information from the original field to the new one:
Expression = 'str(!%s!)' %(orgField)
CalculateField_management(Tab, provField, Expression, 'PYTHON')&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The tool stops at feature 52 of 2500 and gives this Error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;Runtime error &amp;lt;class 'arcgisscripting.ExecuteError'&amp;gt;: ERROR 000539: Error running expression: str("1x jährlich im Herbst zu mühen. Er verwendet Flurname "Hiwes", vormals Parz. 200310&amp;nbsp; ") &amp;lt;type 'exceptions.SyntaxError'&amp;gt;: invalid syntax (&amp;lt;string&amp;gt;, line 1) Failed to execute (CalculateField).&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I assume there is some problem with the " in the string to copy. How can I tell Python to treat the string as one and ignore all special characters?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Jul 2012 12:08:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-539-while-running-calculatefield-to-copy/m-p/246904#M19119</guid>
      <dc:creator>BärbelHorat</dc:creator>
      <dc:date>2012-07-31T12:08:25Z</dc:date>
    </item>
    <item>
      <title>Re: Error 539 while running CalculateField to copy strings</title>
      <link>https://community.esri.com/t5/python-questions/error-539-while-running-calculatefield-to-copy/m-p/246905#M19120</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Bärbel,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;just use the field calculator or try the following reworked script:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Feature class:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Tab = r'\\Tako\gis\03_basisdaten\pronatura\ch\gisdata\pronatura_1.gdb\Schutzgebiete\parz_pn'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;orgField = "Bemerkungen"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;provField = "Bemerkungen_prov"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Adding the new Field:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.AddField_management(Tab,provField,"TEXT", "", "",254)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Copy the information from the original field to the new one:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.CalculateField_management(Tab, provField, orgField, 'PYTHON')&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That should work, if both fields are text fields. There is no need to convert the field to str first.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Kat&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Aug 2012 18:47:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-539-while-running-calculatefield-to-copy/m-p/246905#M19120</guid>
      <dc:creator>KatharinaPalffy-Gelfand</dc:creator>
      <dc:date>2012-08-01T18:47:32Z</dc:date>
    </item>
    <item>
      <title>Re: Error 539 while running CalculateField to copy strings</title>
      <link>https://community.esri.com/t5/python-questions/error-539-while-running-calculatefield-to-copy/m-p/246906#M19121</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for your input, Kat. Unfortunately it still does not work. My script does fine with test data consisting of short strings without special caracters. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your reworked script is not working because of the missing '!' for the field name. If i add the '!', it works with my test data but not with the one i want to work with. Same error.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
#Copy the information from the original field to the new one:
arcpy.CalculateField_management(Tab, provField, !Bemerkungen!, 'PYTHON')&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried it in ArcMap with FieldCalculator. This gives me a new Error. (With test or real data)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;000732: Dataset does not exist or is not supported&lt;/PRE&gt;&lt;SPAN&gt; Witch is quite strange, as I am able to add the data to ArcMap and start the Field Calculator.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Someone else with an Idea?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:17:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-539-while-running-calculatefield-to-copy/m-p/246906#M19121</guid>
      <dc:creator>BärbelHorat</dc:creator>
      <dc:date>2021-12-11T12:17:13Z</dc:date>
    </item>
    <item>
      <title>Re: Error 539 while running CalculateField to copy strings</title>
      <link>https://community.esri.com/t5/python-questions/error-539-while-running-calculatefield-to-copy/m-p/246907#M19122</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;What's different with feature 52 than the others?&amp;nbsp; Seems like this feature is causing the rest of the script to fail.&amp;nbsp; Could you send a screen shot of your attribute table (include feature 52 in the screen shot)?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Aug 2012 10:21:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-539-while-running-calculatefield-to-copy/m-p/246907#M19122</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2012-08-03T10:21:31Z</dc:date>
    </item>
    <item>
      <title>Re: Error 539 while running CalculateField to copy strings</title>
      <link>https://community.esri.com/t5/python-questions/error-539-while-running-calculatefield-to-copy/m-p/246908#M19123</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I now worked some hours on the problem. The Problem are Features (like Feature 52) with ". It seams as CalculateField uses " as string delimiter. It now it workes with those features, if I first substitute all " with ' (using find &amp;amp; replace in ArcMap). Is there a posibility to deal with the " using a script?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The script now causes errors at features with an line break within the textfield. Any ideas how to deal with them in the script? The new Error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Runtime error &amp;lt;class 'arcgisscripting.ExecuteError'&amp;gt;: 
ERROR 000539: Error running expression: "servitude de 'passage à pied' non aménagé sur parcelle 4259
 servitude de 'passage à pied' non aménagé" 
&amp;lt;type 'exceptions.SyntaxError'&amp;gt;: EOL while scanning string literal (&amp;lt;string&amp;gt;, line 1)
Failed to execute (CalculateField). &lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:17:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-539-while-running-calculatefield-to-copy/m-p/246908#M19123</guid>
      <dc:creator>BärbelHorat</dc:creator>
      <dc:date>2021-12-11T12:17:15Z</dc:date>
    </item>
  </channel>
</rss>

