<?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: SearchCursor do not loop after select layer with empty result in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/searchcursor-do-not-loop-after-select-layer-with/m-p/1001220#M59046</link>
    <description>&lt;P&gt;You can try&lt;/P&gt;&lt;LI-CODE lang="python"&gt;arcpy.SelectLayerByAttribute_management('layer', 'new_selection', 'select by attributes who do not exist in layer')&lt;/LI-CODE&gt;&lt;P&gt;after this arcpy tools (Search\UpdateCursor, GetCount, SelectLayerByAttributes(with subset_selection method) or SelectLayerByLocation....) do not see rows&lt;/P&gt;</description>
    <pubDate>Fri, 13 Nov 2020 15:12:56 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2020-11-13T15:12:56Z</dc:date>
    <item>
      <title>SearchCursor do not loop after select layer with empty result</title>
      <link>https://community.esri.com/t5/python-questions/searchcursor-do-not-loop-after-select-layer-with/m-p/1001140#M59038</link>
      <description>&lt;P&gt;I have noticed that after select layer by location/attribute with empty result (example, i tried select layer with attribute, which that do not have), SearchCursor do not see rows in layer table. I tried SearchCursor layer write with dataSource, it's work on *.gdb whom i have physical access, but for *.sde whom i do not have physical access it's do not work ('Cannot open file' error). If i can select all layers features, than SearchCursor will see rows. I know about arcpy.SelectLayerByAttribute, but it is slow. I work with setSelectionSet and after clear selection with setSelectionSet('new', []) is same problem. How me revive layer after select with empty result?&lt;/P&gt;&lt;P&gt;Please, help me and sorry for my English!&lt;/P&gt;</description>
      <pubDate>Fri, 13 Nov 2020 10:10:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/searchcursor-do-not-loop-after-select-layer-with/m-p/1001140#M59038</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2020-11-13T10:10:39Z</dc:date>
    </item>
    <item>
      <title>Re: SearchCursor do not loop after select layer with empty result</title>
      <link>https://community.esri.com/t5/python-questions/searchcursor-do-not-loop-after-select-layer-with/m-p/1001164#M59039</link>
      <description>&lt;P&gt;You need to share your code if you want people to help. Make sure it's &lt;A href="https://community.esri.com/t5/community-help-documents/how-to-insert-code-in-your-post/ta-p/914552" target="_self"&gt;formatted correctly&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Nov 2020 12:10:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/searchcursor-do-not-loop-after-select-layer-with/m-p/1001164#M59039</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2020-11-13T12:10:42Z</dc:date>
    </item>
    <item>
      <title>Re: SearchCursor do not loop after select layer with empty result</title>
      <link>https://community.esri.com/t5/python-questions/searchcursor-do-not-loop-after-select-layer-with/m-p/1001196#M59041</link>
      <description>&lt;P&gt;after clear selection&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;arcpy.mapping.Layer('TreesA').setSelectionSet('new', [])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SearchCursor do not loop rows (result is emty)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;with arcpy.da.SearchCursor('TreesA', ['OBJECTID']) as rs:
...     for r in rs:
...         print r[0]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know about&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;arcpy.SelectLayerByAttribute_management('TreesA', 'clear_selection')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;but this is slow&lt;/P&gt;&lt;P&gt;when i write&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;with arcpy.da.SearchCursor(arcpy.mapping.Layer('TreesA').dataSource, ['OBJECTID']) as rs:
...     for r in rs:
...         print r[0]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SearchCursor see rows (print all OBJECTID)&lt;/P&gt;&lt;P&gt;but when use on *.sde, whom i do not have access&lt;/P&gt;&lt;P&gt;i get:&lt;/P&gt;&lt;P&gt;Runtime error&lt;BR /&gt;Traceback (most recent call last):&lt;BR /&gt;File "&amp;lt;string&amp;gt;", line 1, in &amp;lt;module&amp;gt;&lt;BR /&gt;RuntimeError: &lt;FONT face="arial black,avant garde"&gt;cannot open 'K:\INSTRUKCIJAS\!SDE\backup_connections\PRODSQL_TOPO10_3421-25.sde\PRODSQL_TOPO10.DBO.TOPO10_3\PRODSQL_TOPO10.DBO.TreesA'&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Nov 2020 14:05:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/searchcursor-do-not-loop-after-select-layer-with/m-p/1001196#M59041</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2020-11-13T14:05:10Z</dc:date>
    </item>
    <item>
      <title>Re: SearchCursor do not loop after select layer with empty result</title>
      <link>https://community.esri.com/t5/python-questions/searchcursor-do-not-loop-after-select-layer-with/m-p/1001207#M59042</link>
      <description>&lt;P&gt;If the ObjectID field is what you're getting, try using the&amp;nbsp;&lt;FONT face="courier new,courier"&gt;OID@&lt;/FONT&gt; field name token instead.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Nov 2020 14:45:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/searchcursor-do-not-loop-after-select-layer-with/m-p/1001207#M59042</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2020-11-13T14:45:41Z</dc:date>
    </item>
    <item>
      <title>Re: SearchCursor do not loop after select layer with empty result</title>
      <link>https://community.esri.com/t5/python-questions/searchcursor-do-not-loop-after-select-layer-with/m-p/1001208#M59043</link>
      <description>&lt;P&gt;Yes, i try get features OID list (field name OBJECTID).&lt;/P&gt;&lt;P&gt;Sorry, i am not understood, can you write example!&lt;/P&gt;</description>
      <pubDate>Fri, 13 Nov 2020 14:50:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/searchcursor-do-not-loop-after-select-layer-with/m-p/1001208#M59043</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2020-11-13T14:50:43Z</dc:date>
    </item>
    <item>
      <title>Re: SearchCursor do not loop after select layer with empty result</title>
      <link>https://community.esri.com/t5/python-questions/searchcursor-do-not-loop-after-select-layer-with/m-p/1001212#M59044</link>
      <description>&lt;LI-CODE lang="python"&gt;with arcpy.da.SearchCursor(arcpy.mapping.Layer('TreesA').dataSource, ['OID@']) as rs:&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 13 Nov 2020 14:54:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/searchcursor-do-not-loop-after-select-layer-with/m-p/1001212#M59044</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2020-11-13T14:54:16Z</dc:date>
    </item>
    <item>
      <title>Re: SearchCursor do not loop after select layer with empty result</title>
      <link>https://community.esri.com/t5/python-questions/searchcursor-do-not-loop-after-select-layer-with/m-p/1001214#M59045</link>
      <description>&lt;P&gt;Sorry, nothing changes!&lt;span class="lia-unicode-emoji" title=":pensive_face:"&gt;😔&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Nov 2020 14:58:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/searchcursor-do-not-loop-after-select-layer-with/m-p/1001214#M59045</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2020-11-13T14:58:07Z</dc:date>
    </item>
    <item>
      <title>Re: SearchCursor do not loop after select layer with empty result</title>
      <link>https://community.esri.com/t5/python-questions/searchcursor-do-not-loop-after-select-layer-with/m-p/1001220#M59046</link>
      <description>&lt;P&gt;You can try&lt;/P&gt;&lt;LI-CODE lang="python"&gt;arcpy.SelectLayerByAttribute_management('layer', 'new_selection', 'select by attributes who do not exist in layer')&lt;/LI-CODE&gt;&lt;P&gt;after this arcpy tools (Search\UpdateCursor, GetCount, SelectLayerByAttributes(with subset_selection method) or SelectLayerByLocation....) do not see rows&lt;/P&gt;</description>
      <pubDate>Fri, 13 Nov 2020 15:12:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/searchcursor-do-not-loop-after-select-layer-with/m-p/1001220#M59046</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2020-11-13T15:12:56Z</dc:date>
    </item>
    <item>
      <title>Re: SearchCursor do not loop after select layer with empty result</title>
      <link>https://community.esri.com/t5/python-questions/searchcursor-do-not-loop-after-select-layer-with/m-p/1001406#M59054</link>
      <description>&lt;P&gt;Layer.setSelectionSet has some odd behaviors and Esri's documentation is wrong.&amp;nbsp; Passing an empty list with "New" doesn't clear the selection but creates a new selection with no records, hence why the search cursor is not working.&amp;nbsp; You need to pass an empty set with "New" to have it clear the selection.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Nov 2020 21:09:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/searchcursor-do-not-loop-after-select-layer-with/m-p/1001406#M59054</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-11-13T21:09:14Z</dc:date>
    </item>
    <item>
      <title>Re: SearchCursor do not loop after select layer with empty result</title>
      <link>https://community.esri.com/t5/python-questions/searchcursor-do-not-loop-after-select-layer-with/m-p/1001523#M59055</link>
      <description>&lt;P&gt;Yes, i understood and not only layer.setSelectionSet do it, but SelectLayerByAttribute/Location too. I think about how deteck damaged layer and if found than run&amp;nbsp;SelectLayerByAttribute "clear_selection".&lt;/P&gt;</description>
      <pubDate>Sat, 14 Nov 2020 06:07:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/searchcursor-do-not-loop-after-select-layer-with/m-p/1001523#M59055</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2020-11-14T06:07:22Z</dc:date>
    </item>
    <item>
      <title>Re: SearchCursor do not loop after select layer with empty result</title>
      <link>https://community.esri.com/t5/python-questions/searchcursor-do-not-loop-after-select-layer-with/m-p/1003957#M59111</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous User&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;after this arcpy tools (Search\UpdateCursor, GetCount, SelectLayerByAttributes(with subset_selection method) or SelectLayerByLocation....) do not see rows&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;HR /&gt;&lt;P&gt;This is expected behavior so I am not exactly sure what you are trying to get at with this comment.&amp;nbsp; Most, if not all, geoprocessing tools honor selection sets on layers and table views.&amp;nbsp; If you have a selection set with no records, there is nothing for the tools to operate on.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Nov 2020 14:30:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/searchcursor-do-not-loop-after-select-layer-with/m-p/1003957#M59111</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-11-23T14:30:04Z</dc:date>
    </item>
  </channel>
</rss>

