<?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: Calculate Value Replace Expression in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/calculate-value-replace-expression/m-p/362096#M28582</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanx, your points were right; that is the way I could fix the problem.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Matthias&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 14 Sep 2011 05:50:45 GMT</pubDate>
    <dc:creator>MatthiasAbele</dc:creator>
    <dc:date>2011-09-14T05:50:45Z</dc:date>
    <item>
      <title>Calculate Value Replace Expression</title>
      <link>https://community.esri.com/t5/python-questions/calculate-value-replace-expression/m-p/362094#M28580</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hallo,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'd like to iterate through a list of values. The values are used as field name inline variables and sql-expression for a select command.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To build the sql statement from the list, I use the calculate value function.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;My list elements look like: !0?2,!0?4&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to get the sql-statement by the following command in the calculate Value - tool:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;"%Value%".replace("!",""vges&amp;gt;=").replace("?",".")&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But I always get an error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR 000539: Error running expression: "!0?2".replace("!",""vges&amp;gt;=").replace("?",".") &amp;lt;type 'exceptions.SyntaxError'&amp;gt;: invalid syntax (&amp;lt;string&amp;gt;, line 1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (Calculate Value).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What could be the reason?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Attached an overview from the modell builder.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanx,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Matthias&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Aug 2011 11:55:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculate-value-replace-expression/m-p/362094#M28580</guid>
      <dc:creator>MatthiasAbele</dc:creator>
      <dc:date>2011-08-22T11:55:33Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Value Replace Expression</title>
      <link>https://community.esri.com/t5/python-questions/calculate-value-replace-expression/m-p/362095#M28581</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello there,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't know if the answer to this question is still relevant to you, but there are a couple of things that strike me as strange about your expression:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1) There seems to be an extra quotation mark in your first replace ""vges&amp;gt;=". Alternatively, if you wanted to keep the extra quotation mark, you would either need to escape it ("\"vges&amp;gt;=") or encapsulate the whole string in single quotes ('"vges&amp;gt;=')&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2) The field placeholder for Python snippets is !FieldName! with no quotations around (or the value would be interpreted as a literal.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Either of these could be giving an invalid syntax error. Given the above, I would write the expression as:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;!Value!.replace('!', 'vges&amp;gt;=').replace('?', '.')&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I hope this helps!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Sep 2011 00:31:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculate-value-replace-expression/m-p/362095#M28581</guid>
      <dc:creator>MarcNakleh</dc:creator>
      <dc:date>2011-09-14T00:31:55Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Value Replace Expression</title>
      <link>https://community.esri.com/t5/python-questions/calculate-value-replace-expression/m-p/362096#M28582</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanx, your points were right; that is the way I could fix the problem.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Matthias&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Sep 2011 05:50:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/calculate-value-replace-expression/m-p/362096#M28582</guid>
      <dc:creator>MatthiasAbele</dc:creator>
      <dc:date>2011-09-14T05:50:45Z</dc:date>
    </item>
  </channel>
</rss>

