<?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_management generates ERROR 000539 in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/calculatefield-management-generates-error-000539/m-p/131603#M10210</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I managed to circumvent the problem.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I defined a new function:&amp;nbsp; def dummy():return(AsStack.GetVal())&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.CalculateField_management(tmpcopy, "temp", 'dummy()', "PYTHON") works!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Things won't be as elegant as I hoped, but life is manageable once again.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Wayne&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 18 Nov 2011 15:15:34 GMT</pubDate>
    <dc:creator>WayneHajas</dc:creator>
    <dc:date>2011-11-18T15:15:34Z</dc:date>
    <item>
      <title>CalculateField_management generates ERROR 000539</title>
      <link>https://community.esri.com/t5/python-questions/calculatefield-management-generates-error-000539/m-p/131602#M10209</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am using ARCGIS 10.0.&amp;nbsp; I am trying to populate a field through CalculateField. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The approach I am trying now, is to build a stack-class to contain the values.&amp;nbsp; Then I can use a method from the stack-class as the function that goes into CalculateField.&amp;nbsp; My command looks like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[INDENT][/INDENT]gp.CalculateField_management(tmpcopy, 'temp', 'AsStack.GetVal())', 'PYTHON')&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The resulting error message is: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[INDENT][/INDENT]ExecuteError: ERROR 000539: Error running expression: AsStack.GetVal()) &amp;lt;type 'exceptions.SyntaxError'&amp;gt;: unexpected EOF while parsing (&amp;lt;string&amp;gt;, line 1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (CalculateField).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have confirmed that AsStack.GetVal() gives the correct number of real-values between zero and one.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have found a couple of similar commands that do work:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[INDENT]gp.CalculateField_management(tmpcopy, "temp", 'numpy.random.rand()', "PYTHON")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[/INDENT]gp.CalculateField_management(tmpcopy, "temp", 'AsStack.nval', "PYTHON") (nval is just an integer value)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am running out of things to try.&amp;nbsp; The calculations I am using do require an external library (rpy2).&amp;nbsp; I might be able to avoid the stack-class - but eventually I do think I will need to give CalculateField_managemen a method from a class as the python-expression.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does anybody have a suggestion for what I should try next?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Wayne Hajas&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Nov 2011 21:54:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculatefield-management-generates-error-000539/m-p/131602#M10209</guid>
      <dc:creator>WayneHajas</dc:creator>
      <dc:date>2011-11-17T21:54:03Z</dc:date>
    </item>
    <item>
      <title>Re: CalculateField_management generates ERROR 000539</title>
      <link>https://community.esri.com/t5/python-questions/calculatefield-management-generates-error-000539/m-p/131603#M10210</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I managed to circumvent the problem.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I defined a new function:&amp;nbsp; def dummy():return(AsStack.GetVal())&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.CalculateField_management(tmpcopy, "temp", 'dummy()', "PYTHON") works!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Things won't be as elegant as I hoped, but life is manageable once again.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Wayne&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Nov 2011 15:15:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculatefield-management-generates-error-000539/m-p/131603#M10210</guid>
      <dc:creator>WayneHajas</dc:creator>
      <dc:date>2011-11-18T15:15:34Z</dc:date>
    </item>
    <item>
      <title>Re: CalculateField_management generates ERROR 000539</title>
      <link>https://community.esri.com/t5/python-questions/calculatefield-management-generates-error-000539/m-p/131604#M10211</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I was premature in declaring my stack-method to be a solution.&amp;nbsp; After all the pieces of my application were put together, CalculateField_management did not populate a field - it was just left blank without any error messages.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Fortunately I have discovered UpdateCursor and setValue.&amp;nbsp; They seem to work much more reliably.&amp;nbsp; They are likely not as efficient to use as CalculateField_management - when CalculateField_management works.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Due to the similarity in functionality of CalculateField and setValue, it would be great to have some cross referencing in arcpy.&amp;nbsp; It would have saved me a few hours.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Wayne Hajas&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Dec 2011 16:58:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculatefield-management-generates-error-000539/m-p/131604#M10211</guid>
      <dc:creator>WayneHajas</dc:creator>
      <dc:date>2011-12-23T16:58:13Z</dc:date>
    </item>
  </channel>
</rss>

