<?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: Comparing Fields in gdb and shapefile, using Search Cursor List! in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/comparing-fields-in-gdb-and-shapefile-using-search/m-p/306265#M23762</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I've corrected a few errors I found when I gave it a rest and went back to it. But I am still getting an error on the sort fields.&amp;nbsp; "Search Cursor() got an unexpected keyword argument 'sort_fields'". Could someone please explain that to me. This code is what I need though because it searches the layers in the mxd which is best. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy

flayer = "AADT"
alayer = "AADTAnnoLabel"

FRows = arcpy.SearchCursor(flayer,"", sort_fields="FLAG A")
ARows = arcpy.SearchCursor(alayer,"", sort_fields="TFLAG A")

FList = []
AList = []

for row in FRows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; Fvalue = row.getValue("FLAG")
&amp;nbsp;&amp;nbsp;&amp;nbsp; FList.append(str(Fvalue))

for rows in ARows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; Avalue = row.getValue("TFLAG")
&amp;nbsp;&amp;nbsp;&amp;nbsp; AList.append(str(Avalue))

matched = set(FList) &amp;amp; set(AList)

for x in matched:
&amp;nbsp;&amp;nbsp;&amp;nbsp; exp = "ID = " + x
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(flayer, "ADD_TO_SELECTION", exp)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(flayer, "SWTCH_SELECTION")

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 14:39:21 GMT</pubDate>
    <dc:creator>MichelleCouden1</dc:creator>
    <dc:date>2021-12-11T14:39:21Z</dc:date>
    <item>
      <title>Comparing Fields in gdb and shapefile, using Search Cursor List!</title>
      <link>https://community.esri.com/t5/python-questions/comparing-fields-in-gdb-and-shapefile-using-search/m-p/306260#M23757</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I need some guidance. I am writing a program to search in a field from a shapefile and search in a field in a gdb. I am looking for a value in the gdb that is equal to the value in the shapefile. For Example: If field T_FLAG is 10H59 then it needs to go find that equal in the gdb field TFLAG 10H59. I have started a program I just need to know if I am headed in the right direction or am I way off. Thanks!!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy, os, sys, string&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.overwriteOutput = True&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;fc = "K:\TASS\4_MAPPING_DATA_SUPPORT\Traffic_Mapping\Traffic_Count_Data\2011_Counts\2011_Annual_Stations\Final_Annual_Stations_2012.shp"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;fields = ("TFLAG", "T_FLAG")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Value = "TFLAG" &amp;lt;&amp;gt; "T_FLAG"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;where = "%s = '%s'" % (field, vlaue)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;dhList = []&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for w in ws:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;PRE&gt;&lt;/PRE&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Apr 2013 14:28:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/comparing-fields-in-gdb-and-shapefile-using-search/m-p/306260#M23757</guid>
      <dc:creator>MichelleCouden1</dc:creator>
      <dc:date>2013-04-16T14:28:54Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing Fields in gdb and shapefile, using Search Cursor List!</title>
      <link>https://community.esri.com/t5/python-questions/comparing-fields-in-gdb-and-shapefile-using-search/m-p/306261#M23758</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Here I've added some more:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy, os, sys, string
arcpy.env.overwriteOutput = True
fc = "K:\TASS\4_MAPPING_DATA_SUPPORT\Traffic_Mapping\Traffic_Count_Data\2011_Counts\2011_Annual_Stations\Final_Annual_Stations_2012.shp"
fields = ("TFLAG", "T_FLAG")
Value = "TFLAG" &amp;lt;&amp;gt; "T_FLAG"
where = "%s = '%s'" % (field, vlaue)
dhList = []
for w in ws:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.workspace = w
&amp;nbsp;&amp;nbsp;&amp;nbsp; gdb = arcpy.ListWorkspaces ("*", "TFLAG")
&amp;nbsp;&amp;nbsp;&amp;nbsp; for fc in gdb:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.workspace = fc


&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:39:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/comparing-fields-in-gdb-and-shapefile-using-search/m-p/306261#M23758</guid>
      <dc:creator>MichelleCouden1</dc:creator>
      <dc:date>2021-12-11T14:39:13Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing Fields in gdb and shapefile, using Search Cursor List!</title>
      <link>https://community.esri.com/t5/python-questions/comparing-fields-in-gdb-and-shapefile-using-search/m-p/306262#M23759</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Better Explanation!!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I need help!! I am writing a program where inside the mxd I have two layers. One layer is a shapefile and one layer is the annotation of same shapefile. The program is supposed to find missing annotation in the annotation layer. It's easy because if the annotation is missing there is no data in the attribute table. For example, the shapefile has the field TFlag that has the station id in it and the annotation has the field TFlag that is supposed to have the same id. So, I was going to write the program to look for the same station id in the annotation layer that the station layer has and when it can't find it highlight it. I have written some of the program I need to know if I'm heading in the right direction or am I way off?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Apr 2013 12:49:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/comparing-fields-in-gdb-and-shapefile-using-search/m-p/306262#M23759</guid>
      <dc:creator>MichelleCouden1</dc:creator>
      <dc:date>2013-04-17T12:49:41Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing Fields in gdb and shapefile, using Search Cursor List!</title>
      <link>https://community.esri.com/t5/python-questions/comparing-fields-in-gdb-and-shapefile-using-search/m-p/306263#M23760</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Michelle,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This worked for me, it does assume that all values being compared are unique though.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy

flayer = "Points"
alayer = "PointsAnno"

FRows = arcpy.SearchCursor(flayer,"", sort_fields="ID A")
ARows = arcpy.SearchCursor(alayer,"", sort_fields="TextString A")

FList = []
AList = []

for row in FRows:
 Fvalue = row.getValue("ID")
 FList.append(str(Fvalue))

for row in ARows:
 Avalue = row.getValue("TextString")
 AList.append(str(Avalue))
 
matched = set(FList) &amp;amp; set(AList)

for X in matched:
 exp = "ID = " + X
 arcpy.SelectLayerByAttribute_management(flayer, "ADD_TO_SELECTION", exp)
arcpy.SelectLayerByAttribute_management(flayer, "SWITCH_SELECTION")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Best,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Melanie S.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:39:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/comparing-fields-in-gdb-and-shapefile-using-search/m-p/306263#M23760</guid>
      <dc:creator>MelanieSummers</dc:creator>
      <dc:date>2021-12-11T14:39:16Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing Fields in gdb and shapefile, using Search Cursor List!</title>
      <link>https://community.esri.com/t5/python-questions/comparing-fields-in-gdb-and-shapefile-using-search/m-p/306264#M23761</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Running my code in Python window inside ArcMAP I get a Runtime error. It says "Search Cursor() got an unexpected keyword argument 'sort_fields'" I'm not understanding that because the fields FLAG and TFLAG are the fields in the layer it has to go through. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy, os, sys, string

flayer = "AADT"
alayer = "AADT AnnoLabel"

FRows = arcpy.SearchCursor(flayer,"", sort_fields="FLAG")
ARows = arcpy.SearchCursor(alayer,"", sort_fields="TFLAG")

FList = []
AList = []

for row in FRows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; Fvalue = row.getValue("ID")
&amp;nbsp;&amp;nbsp;&amp;nbsp; FList.append(str(Fvalue))

for rows in ARows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; Avalue = row.getValue("TextString")
&amp;nbsp;&amp;nbsp;&amp;nbsp; AList.append(str(Avalue))

matched = set(FList) &amp;amp; set(AList)

for x in matched:
&amp;nbsp;&amp;nbsp;&amp;nbsp; exp = "ID = " + x
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(flayer, "ADD_TO_SELECTION", exp)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(flayer, "SWTCH_SELECTION")
Runtime error &amp;lt;type 'exceptions.TypeError'&amp;gt;: SearchCursor() got an unexpected keyword argument 'sort_fields'
&amp;gt;&amp;gt;&amp;gt; 

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:39:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/comparing-fields-in-gdb-and-shapefile-using-search/m-p/306264#M23761</guid>
      <dc:creator>MichelleCouden1</dc:creator>
      <dc:date>2021-12-11T14:39:18Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing Fields in gdb and shapefile, using Search Cursor List!</title>
      <link>https://community.esri.com/t5/python-questions/comparing-fields-in-gdb-and-shapefile-using-search/m-p/306265#M23762</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I've corrected a few errors I found when I gave it a rest and went back to it. But I am still getting an error on the sort fields.&amp;nbsp; "Search Cursor() got an unexpected keyword argument 'sort_fields'". Could someone please explain that to me. This code is what I need though because it searches the layers in the mxd which is best. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy

flayer = "AADT"
alayer = "AADTAnnoLabel"

FRows = arcpy.SearchCursor(flayer,"", sort_fields="FLAG A")
ARows = arcpy.SearchCursor(alayer,"", sort_fields="TFLAG A")

FList = []
AList = []

for row in FRows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; Fvalue = row.getValue("FLAG")
&amp;nbsp;&amp;nbsp;&amp;nbsp; FList.append(str(Fvalue))

for rows in ARows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; Avalue = row.getValue("TFLAG")
&amp;nbsp;&amp;nbsp;&amp;nbsp; AList.append(str(Avalue))

matched = set(FList) &amp;amp; set(AList)

for x in matched:
&amp;nbsp;&amp;nbsp;&amp;nbsp; exp = "ID = " + x
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(flayer, "ADD_TO_SELECTION", exp)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(flayer, "SWTCH_SELECTION")

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:39:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/comparing-fields-in-gdb-and-shapefile-using-search/m-p/306265#M23762</guid>
      <dc:creator>MichelleCouden1</dc:creator>
      <dc:date>2021-12-11T14:39:21Z</dc:date>
    </item>
  </channel>
</rss>

