<?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: Using Search Cursor - RuntimeError: Cannot find field 'GlobalID' in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/using-search-cursor-runtimeerror-cannot-find-field/m-p/1150441#M63937</link>
    <description>&lt;P&gt;If I understand what you are trying to do, I would consider a bit of a different approach like this (warning - I did not test this code):&lt;/P&gt;&lt;LI-CODE lang="python"&gt;lyr = arcpy.MakeFeatureLayer_management(NIDs_Joined , "temp_lyr1", "NLDID IS NULL")[0]
arcpy.CopyFeatures_management(lyr, to_append)

lyr = arcpy.MakeFeatureLayer_management(NIDs_Joined , "temp_lyr2", "xy &amp;lt;&amp;gt; xy_1")[0]
arcpy.CopyFeatures_management(lyr, change_loc)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 03 Mar 2022 22:02:03 GMT</pubDate>
    <dc:creator>DonMorrison1</dc:creator>
    <dc:date>2022-03-03T22:02:03Z</dc:date>
    <item>
      <title>Using Search Cursor - RuntimeError: Cannot find field 'GlobalID'</title>
      <link>https://community.esri.com/t5/python-questions/using-search-cursor-runtimeerror-cannot-find-field/m-p/1150262#M63928</link>
      <description>&lt;P&gt;Hello. I have an fc that has been joined to a table. I am trying to use a search cursor and an insert cursor to identify where the rows differ and when they differ, insert them into a blank fc.&amp;nbsp;&lt;/P&gt;&lt;P&gt;For instance, here I am trying to identify where one field has values as null, insert them into the blank fc. I keep getting the following error, and cannot figure out what is going on, as there is a GlobalID field, and I am not even using it here. Appreciate the help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;#begin inserting features into the blank feature classes
searchfields = ["xy", "NIDID_1" , "xy"]
with arcpy.da.SearchCursor(NIDs_Joined,searchfields) as cursor:
    for row in cursor:
        #If the NIDIDs do not align, then this is a new point. Add it to the to_append fc
        if row[1] is None:
            curN.insertRow(row)
        #if the NIDIDs do match but the xy locations are different, add it to the change_loc fc
        if row[0] != row[2]:
            curL.insertRow(row)
Traceback (most recent call last):
  File "&amp;lt;string&amp;gt;", line 7, in &amp;lt;module&amp;gt;
RuntimeError: Cannot find field 'GlobalID'&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Mar 2022 17:28:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-search-cursor-runtimeerror-cannot-find-field/m-p/1150262#M63928</guid>
      <dc:creator>KatHoenke</dc:creator>
      <dc:date>2022-03-03T17:28:21Z</dc:date>
    </item>
    <item>
      <title>Re: Using Search Cursor - RuntimeError: Cannot find field 'GlobalID'</title>
      <link>https://community.esri.com/t5/python-questions/using-search-cursor-runtimeerror-cannot-find-field/m-p/1150292#M63930</link>
      <description>&lt;P&gt;I can't see where "GlobalId' is coming from but there is something odd about your searchfields list. Do you really want to read the same field ('xy') twice? I think you can do that but it seems redundant.&amp;nbsp; Will line 9 ever return True?&amp;nbsp; Perhaps 'xy' is an alias and not really the column name?&lt;/P&gt;&lt;P&gt;It might help to see how you create the curN and curL cursors.&amp;nbsp; For your code to work they must be created with the same number of list elements (3) as the search cursor.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Mar 2022 18:46:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-search-cursor-runtimeerror-cannot-find-field/m-p/1150292#M63930</guid>
      <dc:creator>DonMorrison1</dc:creator>
      <dc:date>2022-03-03T18:46:26Z</dc:date>
    </item>
    <item>
      <title>Re: Using Search Cursor - RuntimeError: Cannot find field 'GlobalID'</title>
      <link>https://community.esri.com/t5/python-questions/using-search-cursor-runtimeerror-cannot-find-field/m-p/1150338#M63934</link>
      <description>&lt;P&gt;Thank you! Essentially, I joined one dataset to an updated version of the same dataset, and calculated xy for both. I want to see if any of the new data xy is different than the old data xy_1, and if it is different, I want to add the row to a new fc (to update my master data). Here is the full code. Please let me know if this can be improved, I'm still learning a lot about how to make my scripts more efficient and better!&lt;/P&gt;&lt;LI-CODE lang="python"&gt;old_NID = r'F:\Analysis\InventoryWork\InventoryUpdateMay2020\Master_Datasets_Western_States\Western_Masters.gdb\NID2020_Schema'
#Join old NID schema to new NID schema
New_NID_join = arcpy.AddJoin_management(schemaone, "NIDID", old_NID, "NIDID", "KEEP_ALL")
NIDs_Joined = arcpy.CopyFeatures_management(New_NID_join, r'F:\Analysis\InventoryWork\InventoryUpdateMay2020\Master_Datasets_Western_States\Analysis\Web Service Work\NID_Versions.gdb\NIDs_Joined')
all_field_names = [f.name for f in arcpy.ListFields(NIDs_Joined)]
print(all_field_names)

# create 3 new fcs - one for new points, one for changing locations, one for changing attributes.

to_append = os.path.join(str(update_sets_gdb), "to_append")
change_loc = os.path.join(str(update_sets_gdb), "change_loc")
change_att = os.path.join(str(update_sets_gdb), "change_att")

#Identify points where locations have changed.
#Copy the joined FC three times and delete all features. These are the blank fcs for the features to be added into.
arcpy.CopyFeatures_management(NIDs_Joined, change_loc)
arcpy.CopyFeatures_management(NIDs_Joined, to_append)
arcpy.CopyFeatures_management(NIDs_Joined, change_att)
arcpy.DeleteFeatures_management(to_append)
arcpy.DeleteFeatures_management(change_loc)
arcpy.DeleteFeatures_management(change_att)

#create insert cursors to insert the features that meet these criteria
curL=arcpy.da.InsertCursor(change_loc,all_field_names)
curA=arcpy.da.InsertCursor(change_att,all_field_names)
curN=arcpy.da.InsertCursor(to_append,all_field_names)

#begin inserting features into the blank feature classes
searchfields = ["xy", "NIDID_1" , "xy"]
with arcpy.da.SearchCursor(NIDs_Joined,searchfields) as cursor:
    for row in cursor:
        #If the NIDIDs do not align, then this is a new point. Add it to the to_append fc
        if row[1] is None:
            curN.insertRow(row)
        #if the NIDIDs do match but the xy locations are different, add it to the change_loc fc
        if row[0] != row[2]:
            curL.insertRow(row)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Mar 2022 19:41:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-search-cursor-runtimeerror-cannot-find-field/m-p/1150338#M63934</guid>
      <dc:creator>KatHoenke</dc:creator>
      <dc:date>2022-03-03T19:41:38Z</dc:date>
    </item>
    <item>
      <title>Re: Using Search Cursor - RuntimeError: Cannot find field 'GlobalID'</title>
      <link>https://community.esri.com/t5/python-questions/using-search-cursor-runtimeerror-cannot-find-field/m-p/1150342#M63935</link>
      <description>&lt;P&gt;I think that you figured it out - my cursors are pointing to the wrong field list. That fixed it! Thank you! Here is the updated script.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;searchfields = ["xy", "NIDID_1" , "xy_1"]
#create insert cursors to insert the features that meet these criteria
curL=arcpy.da.InsertCursor(change_loc,searchfields)
curA=arcpy.da.InsertCursor(change_att, all_field_names)
curN=arcpy.da.InsertCursor(to_append, searchfields)

#begin inserting features into the blank feature classes
with arcpy.da.SearchCursor(NIDs_Joined,searchfields) as cursor:
    for row in cursor:
        #If the NIDIDs do not align, then this is a new point. Add it to the to_append fc
        if row[1] is None:
            curN.insertRow(row)
        #if the NIDIDs do match but the xy locations are different, add it to the change_loc fc
        if row[0] != row[2]:
            curL.insertRow(row)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Mar 2022 19:48:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-search-cursor-runtimeerror-cannot-find-field/m-p/1150342#M63935</guid>
      <dc:creator>KatHoenke</dc:creator>
      <dc:date>2022-03-03T19:48:17Z</dc:date>
    </item>
    <item>
      <title>Re: Using Search Cursor - RuntimeError: Cannot find field 'GlobalID'</title>
      <link>https://community.esri.com/t5/python-questions/using-search-cursor-runtimeerror-cannot-find-field/m-p/1150349#M63936</link>
      <description>&lt;P&gt;Is there a way to above, use only 3 fields to search but to insert rows with all fields?&lt;/P&gt;&lt;P&gt;I've updated my searchfields to include fields without globalid, but now I get the error that the workspace is already in transaction mode.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Mar 2022 20:11:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-search-cursor-runtimeerror-cannot-find-field/m-p/1150349#M63936</guid>
      <dc:creator>KatHoenke</dc:creator>
      <dc:date>2022-03-03T20:11:17Z</dc:date>
    </item>
    <item>
      <title>Re: Using Search Cursor - RuntimeError: Cannot find field 'GlobalID'</title>
      <link>https://community.esri.com/t5/python-questions/using-search-cursor-runtimeerror-cannot-find-field/m-p/1150441#M63937</link>
      <description>&lt;P&gt;If I understand what you are trying to do, I would consider a bit of a different approach like this (warning - I did not test this code):&lt;/P&gt;&lt;LI-CODE lang="python"&gt;lyr = arcpy.MakeFeatureLayer_management(NIDs_Joined , "temp_lyr1", "NLDID IS NULL")[0]
arcpy.CopyFeatures_management(lyr, to_append)

lyr = arcpy.MakeFeatureLayer_management(NIDs_Joined , "temp_lyr2", "xy &amp;lt;&amp;gt; xy_1")[0]
arcpy.CopyFeatures_management(lyr, change_loc)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Mar 2022 22:02:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-search-cursor-runtimeerror-cannot-find-field/m-p/1150441#M63937</guid>
      <dc:creator>DonMorrison1</dc:creator>
      <dc:date>2022-03-03T22:02:03Z</dc:date>
    </item>
  </channel>
</rss>

