<?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: Set Function with addtional field printed in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/set-function-with-addtional-field-printed/m-p/151007#M11678</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do the FacilityID and NAME fields contain the same information? In my post &lt;A href="https://community.esri.com/docs/DOC-1927" target="_blank"&gt;Some Python Snippets&lt;/A&gt; you can see how to work with sets and lists:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Compare two lists and get the items in list 1 but not in list 2
listDifference = list(set(myList1) - set(myList2))

# Compare two lists and get the items that are in both lists
listSame = list(set(myList1) &amp;amp; set(myList2))

# join or merge two sets
new_set = first_set.union(other_set)
# or:
new_set = set(list(first_set) + list(other_set))&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 08:07:23 GMT</pubDate>
    <dc:creator>XanderBakker</dc:creator>
    <dc:date>2021-12-11T08:07:23Z</dc:date>
    <item>
      <title>Set Function with addtional field printed</title>
      <link>https://community.esri.com/t5/python-questions/set-function-with-addtional-field-printed/m-p/151006#M11677</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Some help on this please, Thanks&lt;/P&gt;&lt;P&gt;Script work works great for finding Facilityid numbers not found in “b” or final =a-b. But to make the script more useful an additional field or&lt;BR /&gt;“NAME” should be printed in conjunction with the Facilityid number or “FACILITYID &amp;amp; NAME” and this is where I need some help. The “NAME” field contains text (ex:“Redondo Tank”) and is difficult to add or subtract and the set function works perfect for my task. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Larry Adgate&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Import arcpy module&lt;BR /&gt;import arcpy&lt;/P&gt;&lt;P&gt;# Local variables:&lt;BR /&gt;Index = "C:\\Projects\\UpdatePlantFacilityIndex.mdb\\FacilityIndex2013"&lt;BR /&gt;Arden_ns = "C:\\Projects\\UpdatePlantFacilityIndex.mdb\\UpdatePlantFacilityIndex\\Network"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;a = set(r[0] for r in arcpy.da.SearchCursor(Index, ["FACILITYID"]))&lt;BR /&gt;&lt;STRONG&gt;a1 = set(r[0] for r in arcpy.da.SearchCursor(Index, ["NAME"])) #Addition field data to accompany FacilityID&lt;/STRONG&gt;&lt;BR /&gt;b = set(r[0] for r in arcpy.da.SearchCursor(Arden_ns, ["FacilityID"]))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;final = a+a1-b&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;print "Arden System Discrepency: {0},".format(", ".join(sorted(final)))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#error Message:&amp;nbsp;&amp;nbsp;&amp;nbsp; final = a+a1-b&lt;BR /&gt;#error message: TypeError: unsupported operand type(s) for +: 'set' and 'set'&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Feb 2015 16:49:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/set-function-with-addtional-field-printed/m-p/151006#M11677</guid>
      <dc:creator>LarryAdgate</dc:creator>
      <dc:date>2015-02-09T16:49:39Z</dc:date>
    </item>
    <item>
      <title>Re: Set Function with addtional field printed</title>
      <link>https://community.esri.com/t5/python-questions/set-function-with-addtional-field-printed/m-p/151007#M11678</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do the FacilityID and NAME fields contain the same information? In my post &lt;A href="https://community.esri.com/docs/DOC-1927" target="_blank"&gt;Some Python Snippets&lt;/A&gt; you can see how to work with sets and lists:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Compare two lists and get the items in list 1 but not in list 2
listDifference = list(set(myList1) - set(myList2))

# Compare two lists and get the items that are in both lists
listSame = list(set(myList1) &amp;amp; set(myList2))

# join or merge two sets
new_set = first_set.union(other_set)
# or:
new_set = set(list(first_set) + list(other_set))&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 08:07:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/set-function-with-addtional-field-printed/m-p/151007#M11678</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-11T08:07:23Z</dc:date>
    </item>
    <item>
      <title>Re: Set Function with addtional field printed</title>
      <link>https://community.esri.com/t5/python-questions/set-function-with-addtional-field-printed/m-p/151008#M11679</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Xander Thanks for your Help&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The " FacilityId" Field will contains numbers such as NS1025, NS1008, NS1010, CS1002&lt;/P&gt;&lt;P&gt;The "NAME" Field will contain text data such as- Redondo Tank, Sludge Tank, Pacific Tank&lt;/P&gt;&lt;P&gt;A Typical Print out would say:&amp;nbsp;&amp;nbsp; NS1025&amp;nbsp; Redondo Tank&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NS1008&amp;nbsp; Sludge Tank&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NS1010&amp;nbsp; Pacific Tank&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;Larry&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Feb 2015 18:09:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/set-function-with-addtional-field-printed/m-p/151008#M11679</guid>
      <dc:creator>LarryAdgate</dc:creator>
      <dc:date>2015-02-09T18:09:50Z</dc:date>
    </item>
    <item>
      <title>Re: Set Function with addtional field printed</title>
      <link>https://community.esri.com/t5/python-questions/set-function-with-addtional-field-printed/m-p/151009#M11680</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
Index = "C:\\Projects\\UpdatePlantFacilityIndex.mdb\\FacilityIndex2013"
Arden_ns = "C:\\Projects\\UpdatePlantFacilityIndex.mdb\\UpdatePlantFacilityIndex\\Network"

# list of facility ID's in Arden_ns
b = set(r[0] for r in arcpy.da.SearchCursor(Arden_ns, ["FacilityID"]))

# list facilities not in arden_ns
flds= ("FACILITYID", "NAME")
dct = {r[0]: r[1] for r in arcpy.da.SearchCursor(Index, flds) if not r[0] in b}

# print list
for fac_id, name in sorted(dct.items()):
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "{0}: {1}".format(fac_id, name)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 08:07:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/set-function-with-addtional-field-printed/m-p/151009#M11680</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-11T08:07:25Z</dc:date>
    </item>
    <item>
      <title>Re: Set Function with addtional field printed</title>
      <link>https://community.esri.com/t5/python-questions/set-function-with-addtional-field-printed/m-p/151010#M11681</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Xander,&amp;nbsp; the script worked great. My plans were to run&amp;nbsp; the Index againt 38 other feature classes and this will give me food for thought. Thanks, Larry&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Feb 2015 20:55:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/set-function-with-addtional-field-printed/m-p/151010#M11681</guid>
      <dc:creator>LarryAdgate</dc:creator>
      <dc:date>2015-02-09T20:55:41Z</dc:date>
    </item>
  </channel>
</rss>

