<?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: Searching for values in other tables in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/searching-for-values-in-other-tables/m-p/263356#M20320</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you, Xander!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 27 Nov 2017 18:23:42 GMT</pubDate>
    <dc:creator>MitchHolley1</dc:creator>
    <dc:date>2017-11-27T18:23:42Z</dc:date>
    <item>
      <title>Searching for values in other tables</title>
      <link>https://community.esri.com/t5/python-questions/searching-for-values-in-other-tables/m-p/263350#M20314</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm relatively new to GIS and Python and am trying to find a way to build a model that will feedback to be whether there is a matching value from one table in another.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In other words, I need to know&amp;nbsp;which (if any) of&amp;nbsp;my values from 'column 1' of 'table 1' appear in 'column 3' of 'table 2'. I know how to do this manually, however there are over 18000 values in&amp;nbsp;&lt;SPAN&gt;'column 1' of 'table 1' and 28000 in&amp;nbsp;'column 3' of 'table 2' so automating this will save a lot of time.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Nov 2017 11:09:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/searching-for-values-in-other-tables/m-p/263350#M20314</guid>
      <dc:creator>ANNAPRIOR1</dc:creator>
      <dc:date>2017-11-27T11:09:58Z</dc:date>
    </item>
    <item>
      <title>Re: Searching for values in other tables</title>
      <link>https://community.esri.com/t5/python-questions/searching-for-values-in-other-tables/m-p/263351#M20315</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you functionally explain how you would like to see this work. You can easily do this manually and provide this information at table 1 perhaps as an additional field, but you want to use a model (Model Builder?) for this and create a tool that verifies the existence of a selected value of your 'column 1' in 'column 3' of table 2?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you just want to report which values from table 1 occur in table 2 or which ones don't you should use sets. See some examples here:&amp;nbsp;&lt;A href="https://community.esri.com/docs/DOC-1927" target="_blank"&gt;Some Python Snippets&lt;/A&gt;&amp;nbsp; (scroll down to&amp;nbsp;&lt;EM&gt;Compare lists and dictionaries&lt;/EM&gt;).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example:&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

tbl1 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;'your path to table 1'&lt;/SPAN&gt;
fld1 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'column1'&lt;/SPAN&gt;
tbl2 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;'your path to table 2'&lt;/SPAN&gt;
fld2 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'column2'&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# create a list of the values in table 1, column 1&lt;/SPAN&gt;
lst1 &lt;SPAN class="operator 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;tbl1&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fld1&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="comment token"&gt;# create a list of the values in table 2, column 2&lt;/SPAN&gt;
lst2 &lt;SPAN class="operator 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;tbl2&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fld2&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="comment token"&gt;# Compare the two lists and get the items in list 1 but not in list 2&lt;/SPAN&gt;
lstin1notin2 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; list&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;set&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;lst1&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt; set&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;lst2&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# Compare the two lists and get the items in list 2 but not in list 1&lt;/SPAN&gt;
lstin2notin1 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; list&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;set&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;lst2&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt; set&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;lst1&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# Compare two lists and get the items that are in both lists&lt;/SPAN&gt;
lstinboth &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; list&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;set&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;lst1&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;amp;&lt;/SPAN&gt; set&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;lst2&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;/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;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This is for comparing two lists, but you cam also check a single value in a list of values:&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

value1 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'a value from table 1 column 1'&lt;/SPAN&gt;
tbl2 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;'your path to table 2'&lt;/SPAN&gt;
fld2 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'column2'&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# create a list of the values in table 2, column 2&lt;/SPAN&gt;
lst2 &lt;SPAN class="operator 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;tbl2&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fld2&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="keyword token"&gt;if&lt;/SPAN&gt; value1 &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; lst2&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"value 1 is in list 2"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&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; &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"value 1 is not in list 2"&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;/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;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:54:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/searching-for-values-in-other-tables/m-p/263351#M20315</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-11T12:54:33Z</dc:date>
    </item>
    <item>
      <title>Re: Searching for values in other tables</title>
      <link>https://community.esri.com/t5/python-questions/searching-for-values-in-other-tables/m-p/263352#M20316</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This tool will let you select values based on shared values in another table view:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="http://pm.maps.arcgis.com/home/item.html?id=e638afe0695a4ad38388cb8d9b350446" title="http://pm.maps.arcgis.com/home/item.html?id=e638afe0695a4ad38388cb8d9b350446"&gt;http://pm.maps.arcgis.com/home/item.html?id=e638afe0695a4ad38388cb8d9b350446&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Nov 2017 16:38:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/searching-for-values-in-other-tables/m-p/263352#M20316</guid>
      <dc:creator>BruceHarold</dc:creator>
      <dc:date>2017-11-27T16:38:53Z</dc:date>
    </item>
    <item>
      <title>Re: Searching for values in other tables</title>
      <link>https://community.esri.com/t5/python-questions/searching-for-values-in-other-tables/m-p/263353#M20317</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What tool are you referring to? &amp;nbsp;The link is not working for me.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Nov 2017 16:47:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/searching-for-values-in-other-tables/m-p/263353#M20317</guid>
      <dc:creator>MitchHolley1</dc:creator>
      <dc:date>2017-11-27T16:47:01Z</dc:date>
    </item>
    <item>
      <title>Re: Searching for values in other tables</title>
      <link>https://community.esri.com/t5/python-questions/searching-for-values-in-other-tables/m-p/263354#M20318</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is accessible to:&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/384910_pastedImage_1.png" style="width: 620px; height: 289px;" /&gt;&lt;/P&gt;&lt;P&gt;Download contains toolbox and script:&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/385025_pastedImage_2.png" style="width: 620px; height: 346px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Maybe try https?&amp;nbsp;&lt;A class="link-titled" href="https://pm.maps.arcgis.com/home/item.html?id=e638afe0695a4ad38388cb8d9b350446" title="https://pm.maps.arcgis.com/home/item.html?id=e638afe0695a4ad38388cb8d9b350446"&gt;https://pm.maps.arcgis.com/home/item.html?id=e638afe0695a4ad38388cb8d9b350446&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Nov 2017 18:00:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/searching-for-values-in-other-tables/m-p/263354#M20318</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2017-11-27T18:00:17Z</dc:date>
    </item>
    <item>
      <title>Re: Searching for values in other tables</title>
      <link>https://community.esri.com/t5/python-questions/searching-for-values-in-other-tables/m-p/263355#M20319</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I &lt;STRONG&gt;&lt;EM&gt;think&lt;/EM&gt; &lt;/STRONG&gt;this is the zip payload.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Nov 2017 18:06:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/searching-for-values-in-other-tables/m-p/263355#M20319</guid>
      <dc:creator>BruceHarold</dc:creator>
      <dc:date>2017-11-27T18:06:30Z</dc:date>
    </item>
    <item>
      <title>Re: Searching for values in other tables</title>
      <link>https://community.esri.com/t5/python-questions/searching-for-values-in-other-tables/m-p/263356#M20320</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you, Xander!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Nov 2017 18:23:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/searching-for-values-in-other-tables/m-p/263356#M20320</guid>
      <dc:creator>MitchHolley1</dc:creator>
      <dc:date>2017-11-27T18:23:42Z</dc:date>
    </item>
    <item>
      <title>Re: Searching for values in other tables</title>
      <link>https://community.esri.com/t5/python-questions/searching-for-values-in-other-tables/m-p/263357#M20321</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you so much! Myself and my colleagues have been tearing our hair out for days trying to work this out&amp;nbsp;and this works perfectly and will honestly save us hours a week.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Nov 2017 09:15:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/searching-for-values-in-other-tables/m-p/263357#M20321</guid>
      <dc:creator>ANNAPRIOR1</dc:creator>
      <dc:date>2017-11-28T09:15:51Z</dc:date>
    </item>
    <item>
      <title>Re: Searching for values in other tables</title>
      <link>https://community.esri.com/t5/python-questions/searching-for-values-in-other-tables/m-p/263358#M20322</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://community.esri.com/migrated-users/302039"&gt;ANNA PRIOR&lt;/A&gt;&amp;nbsp;, I'm glad you were able to resolve it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Did you use the toolbox provided by&amp;nbsp;&lt;A href="https://community.esri.com/migrated-users/3241"&gt;Bruce Harold&lt;/A&gt;&amp;nbsp;? If so, please mark&amp;nbsp;his post as the correct one ("Mark Correct") so that others can find that solution too. If it was another solution please mark the corresponding post as the correct answer.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Nov 2017 11:41:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/searching-for-values-in-other-tables/m-p/263358#M20322</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2017-11-28T11:41:11Z</dc:date>
    </item>
  </channel>
</rss>

