<?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: Arcpy - Compare values from 2 feature classes in Python Snippets Questions</title>
    <link>https://community.esri.com/t5/python-snippets-questions/arcpy-compare-values-from-2-feature-classes/m-p/825480#M375</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Awesome! Thanks Xander...much appreciated.&lt;/P&gt;&lt;P&gt;I’m sure I can work things out from here...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 24 Jul 2018 12:29:17 GMT</pubDate>
    <dc:creator>timdunlevie1</dc:creator>
    <dc:date>2018-07-24T12:29:17Z</dc:date>
    <item>
      <title>Arcpy - Compare values from 2 feature classes</title>
      <link>https://community.esri.com/t5/python-snippets-questions/arcpy-compare-values-from-2-feature-classes/m-p/825478#M373</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I'm trying to compare data values in 2 separate feature classes and find out what has changed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FCnew | FIELDA (shapefile or feature class)&lt;/P&gt;&lt;P&gt;FCmaster | FIELDA (feature class in a fgdb)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FCnew is periodically being updated by external source - this can have new values or have original values removed.&lt;/P&gt;&lt;P&gt;FCmaster is the master table I manage. This consists of the original FCnew values, and will change periodically from the FCnew.&lt;/P&gt;&lt;P&gt;What I currently do in arcpy is join a master set of objects to FCnew attributes and then truncate FCmaster and append current records.&lt;/P&gt;&lt;P&gt;Now I want to show what has changed as well....ideally saved to a text file.&lt;/P&gt;&lt;P&gt;So all I want to do is compare the 2 fields (FIELDA) and print out what values are different.&lt;/P&gt;&lt;P&gt;I've had a look at table compare etc... but find it hard to just tell me what values have changed from one field.&lt;/P&gt;&lt;P&gt;I was thinking of building dictionaries of each set in arcpy and somehow comparing those lists?&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated.&lt;/P&gt;&lt;P&gt;Just put me onto the right course....!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using ArcGIS Desktop 10.6.1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Jul 2018 09:49:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/arcpy-compare-values-from-2-feature-classes/m-p/825478#M373</guid>
      <dc:creator>timdunlevie1</dc:creator>
      <dc:date>2018-07-24T09:49:42Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy - Compare values from 2 feature classes</title>
      <link>https://community.esri.com/t5/python-snippets-questions/arcpy-compare-values-from-2-feature-classes/m-p/825479#M374</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Probably the most simple way of doing this is using sets. Sets are comparable with lists,&amp;nbsp; but only contains unique values. To create a set from a field in a featureclass you can use&amp;nbsp;something simple as:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy

fc &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;'your path to the master or new featureclass'&lt;/SPAN&gt;
fld_name &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'Your Field Name'&lt;/SPAN&gt;

fld_set &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; set&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;r&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; r &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;da&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SearchCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fc&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fld_name&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&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;/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;If you do this for both featureclasses you end up with two sets of values. Once you have the sets, comparing is easy. For instance, look at the&amp;nbsp;snippet below:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy

fc_master &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;'your path to the master featureclass'&lt;/SPAN&gt;
fld_name_master &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'Your Field Name'&lt;/SPAN&gt;
fc_new &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;'your path to the new featureclass'&lt;/SPAN&gt;
fld_name_new &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'Your Field Name'&lt;/SPAN&gt;

set_master &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; set&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;r&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; r &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;da&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SearchCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fc_master&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fld_name_master&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
set_new &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; set&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;r&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; r &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;da&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SearchCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fc_new&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fld_name_new&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

lst_in_new_not_in_master &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; list&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;set_new &lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt; set_master&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
lst_in_master_not_in_new &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; list&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;set_master &lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt; set_new&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
lst_in_both &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; list&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;set_master &lt;SPAN class="operator token"&gt;&amp;amp;&lt;/SPAN&gt; set_new&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;/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;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;This will create 3 lists with:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;those values that are in the new featureclass yet not in the master&lt;/LI&gt;&lt;LI&gt;those values that are in the master but not in the new featureclass&lt;/LI&gt;&lt;LI&gt;values that are both in the master and the new featureclass&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm sure that once you have these lists you want to do something with it or perhaps you want to know which ObjectIDs correspond to these values. This can also be done.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;More info&amp;nbsp;on list comparisons:&amp;nbsp;&lt;A href="https://community.esri.com/docs/DOC-1927" target="_blank"&gt;https://community.esri.com/docs/DOC-1927&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 09:50:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/arcpy-compare-values-from-2-feature-classes/m-p/825479#M374</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-12T09:50:14Z</dc:date>
    </item>
    <item>
      <title>Re: Arcpy - Compare values from 2 feature classes</title>
      <link>https://community.esri.com/t5/python-snippets-questions/arcpy-compare-values-from-2-feature-classes/m-p/825480#M375</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Awesome! Thanks Xander...much appreciated.&lt;/P&gt;&lt;P&gt;I’m sure I can work things out from here...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Jul 2018 12:29:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-snippets-questions/arcpy-compare-values-from-2-feature-classes/m-p/825480#M375</guid>
      <dc:creator>timdunlevie1</dc:creator>
      <dc:date>2018-07-24T12:29:17Z</dc:date>
    </item>
  </channel>
</rss>

