<?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 using the field calculator with python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/using-the-field-calculator-with-python/m-p/682594#M52862</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, &lt;/P&gt;&lt;P&gt;So i am trying to use the field calculator using python to determine the input for the field. So for example my table has 2 fields(both text fields(one of the fields would be empty at this point)), i would like the code to say If field one is "String 1" then put in field 2 "string 2". Basically i want it to check the value of field one and if it matches the string i am looking for then i want it to write another string that i decide in the code to write. I was wondering if&amp;nbsp; someone had a template of a similar code that i can look at to get an idea on how to write it. Preferable in python but i think VB works also. Thanks in advance&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 27 Jul 2016 18:41:10 GMT</pubDate>
    <dc:creator>LeifJohnson</dc:creator>
    <dc:date>2016-07-27T18:41:10Z</dc:date>
    <item>
      <title>using the field calculator with python</title>
      <link>https://community.esri.com/t5/python-questions/using-the-field-calculator-with-python/m-p/682594#M52862</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, &lt;/P&gt;&lt;P&gt;So i am trying to use the field calculator using python to determine the input for the field. So for example my table has 2 fields(both text fields(one of the fields would be empty at this point)), i would like the code to say If field one is "String 1" then put in field 2 "string 2". Basically i want it to check the value of field one and if it matches the string i am looking for then i want it to write another string that i decide in the code to write. I was wondering if&amp;nbsp; someone had a template of a similar code that i can look at to get an idea on how to write it. Preferable in python but i think VB works also. Thanks in advance&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Jul 2016 18:41:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-the-field-calculator-with-python/m-p/682594#M52862</guid>
      <dc:creator>LeifJohnson</dc:creator>
      <dc:date>2016-07-27T18:41:10Z</dc:date>
    </item>
    <item>
      <title>Re: using the field calculator with python</title>
      <link>https://community.esri.com/t5/python-questions/using-the-field-calculator-with-python/m-p/682595#M52863</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;the best bet would be to either show the code you are trying to implement or show the field calculator syntax you are using since your description is a bit of both&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Jul 2016 21:58:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-the-field-calculator-with-python/m-p/682595#M52863</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-07-27T21:58:18Z</dc:date>
    </item>
    <item>
      <title>Re: using the field calculator with python</title>
      <link>https://community.esri.com/t5/python-questions/using-the-field-calculator-with-python/m-p/682596#M52864</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;See the third example on this page, which uses if-then logic in a code block: &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/tools/data-management-toolbox/calculate-field.htm" title="http://desktop.arcgis.com/en/arcmap/latest/tools/data-management-toolbox/calculate-field.htm"&gt;Calculate Field—Help | ArcGIS for Desktop&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Jul 2016 22:04:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-the-field-calculator-with-python/m-p/682596#M52864</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2016-07-27T22:04:54Z</dc:date>
    </item>
    <item>
      <title>Re: using the field calculator with python</title>
      <link>https://community.esri.com/t5/python-questions/using-the-field-calculator-with-python/m-p/682597#M52865</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So you basically want to calculate Field 2 based on the value in Field 1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your Python code block can look like this:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;calcfield&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;field1&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp; val &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;""&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; field1 &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"test"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; val &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"string 2"&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; val &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"other string"&lt;/SPAN&gt;
 &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; val‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And the field calculation expression:&lt;/P&gt;&lt;P&gt;Field2 =&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;calcfield&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;!MyField!&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 04:43:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-the-field-calculator-with-python/m-p/682597#M52865</guid>
      <dc:creator>FC_Basson</dc:creator>
      <dc:date>2021-12-12T04:43:10Z</dc:date>
    </item>
  </channel>
</rss>

