<?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: python script for attribute table field calculator in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-script-for-attribute-table-field-calculator/m-p/68998#M5631</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When using an &lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;if&lt;/SPAN&gt; statement, you probably have to use the &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/tools/data-management-toolbox/calculate-field-examples.htm#ESRI_SECTION1_DF13F7EE4AF345CAAA46C1CFA2F7BFE1" rel="nofollow noopener noreferrer" target="_blank"&gt;field calculator code block option&lt;/A&gt;. You also mixed up the field name syntax between VB and Python.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;code block:&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;compareCalc&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;col1&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; col3&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; col1 &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; col3&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'yes'&lt;/SPAN&gt;
&amp;nbsp;&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;&amp;nbsp; &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'no'&lt;/SPAN&gt;‍‍‍‍‍&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;expression:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;compareCalc&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;!column1!&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; !column3!&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>Fri, 10 Dec 2021 22:38:37 GMT</pubDate>
    <dc:creator>BlakeTerhune</dc:creator>
    <dc:date>2021-12-10T22:38:37Z</dc:date>
    <item>
      <title>python script for attribute table field calculator</title>
      <link>https://community.esri.com/t5/python-questions/python-script-for-attribute-table-field-calculator/m-p/68993#M5626</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm using ArcMap 10.2. I have 2 columns in a joined table that I need to compare. They need to have the exact same content, and there are about 3,000 rows. I tried this: (changed field names for security)&lt;/P&gt;&lt;P&gt;[column1] ==!column3!&lt;BR /&gt;&amp;nbsp; &amp;nbsp;return yes&lt;BR /&gt;else:&lt;BR /&gt;&amp;nbsp; &amp;nbsp;return no&lt;/P&gt;&lt;P&gt;the Field calculation failed. I think I'm forgetting something really basic in the python script. I would appreciate any advice.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Jun 2017 23:43:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-for-attribute-table-field-calculator/m-p/68993#M5626</guid>
      <dc:creator>FaithWebster</dc:creator>
      <dc:date>2017-06-28T23:43:27Z</dc:date>
    </item>
    <item>
      <title>Re: python script for attribute table field calculator</title>
      <link>https://community.esri.com/t5/python-questions/python-script-for-attribute-table-field-calculator/m-p/68994#M5627</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Rather than fiddling around with a script...&lt;/P&gt;&lt;P&gt;1&amp;nbsp; Add a text/string field to your table... call it ... Check ... or something&lt;/P&gt;&lt;P&gt;2 Select by attribute ....&amp;nbsp; field1 == field2&lt;/P&gt;&lt;P&gt;3&amp;nbsp; make ... Check... the active field and open the field calculator and type 'yes' with the single quotes around the word&lt;/P&gt;&lt;P&gt;4&amp;nbsp; from the table, hit the switch selection button to get the reverse&lt;/P&gt;&lt;P&gt;5&amp;nbsp; from the Check field... type 'no'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you should now have all records filled ...Unless... you have Null values in your fields since a value won't compare to null.&amp;nbsp; If you have any of those, then get back&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jun 2017 01:41:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-for-attribute-table-field-calculator/m-p/68994#M5627</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2017-06-29T01:41:56Z</dc:date>
    </item>
    <item>
      <title>Re: python script for attribute table field calculator</title>
      <link>https://community.esri.com/t5/python-questions/python-script-for-attribute-table-field-calculator/m-p/68995#M5628</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;besides what Dan said, always make sure you have a space on both sides of the ==&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at least in your post it looks like the space is missing after the before the !&amp;nbsp;&amp;nbsp;&amp;nbsp; (which may just be a typo in the post)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jun 2017 14:43:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-for-attribute-table-field-calculator/m-p/68995#M5628</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2017-06-29T14:43:47Z</dc:date>
    </item>
    <item>
      <title>Re: python script for attribute table field calculator</title>
      <link>https://community.esri.com/t5/python-questions/python-script-for-attribute-table-field-calculator/m-p/68996#M5629</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you! That is a much easier solution!&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jun 2017 14:50:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-for-attribute-table-field-calculator/m-p/68996#M5629</guid>
      <dc:creator>FaithWebster</dc:creator>
      <dc:date>2017-06-29T14:50:11Z</dc:date>
    </item>
    <item>
      <title>Re: python script for attribute table field calculator</title>
      <link>https://community.esri.com/t5/python-questions/python-script-for-attribute-table-field-calculator/m-p/68997#M5630</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just a note: the select by attribute uses SQL and the expression was field 1=field 2. it worked perfectly!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jun 2017 15:01:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-for-attribute-table-field-calculator/m-p/68997#M5630</guid>
      <dc:creator>FaithWebster</dc:creator>
      <dc:date>2017-06-29T15:01:23Z</dc:date>
    </item>
    <item>
      <title>Re: python script for attribute table field calculator</title>
      <link>https://community.esri.com/t5/python-questions/python-script-for-attribute-table-field-calculator/m-p/68998#M5631</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When using an &lt;SPAN style="font-family: 'courier new', courier, monospace;"&gt;if&lt;/SPAN&gt; statement, you probably have to use the &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/tools/data-management-toolbox/calculate-field-examples.htm#ESRI_SECTION1_DF13F7EE4AF345CAAA46C1CFA2F7BFE1" rel="nofollow noopener noreferrer" target="_blank"&gt;field calculator code block option&lt;/A&gt;. You also mixed up the field name syntax between VB and Python.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;code block:&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;compareCalc&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;col1&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; col3&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; col1 &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; col3&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'yes'&lt;/SPAN&gt;
&amp;nbsp;&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;&amp;nbsp; &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'no'&lt;/SPAN&gt;‍‍‍‍‍&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;expression:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;compareCalc&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;!column1!&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; !column3!&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>Fri, 10 Dec 2021 22:38:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-for-attribute-table-field-calculator/m-p/68998#M5631</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2021-12-10T22:38:37Z</dc:date>
    </item>
  </channel>
</rss>

