<?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 Deleting Features: Does cursor mess with order? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/deleting-features-does-cursor-mess-with-order/m-p/574765#M45037</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;Question:&lt;/P&gt;&lt;P&gt;I have read that cursors can only be iterated forward, not in reversed order.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not if I have e.g. 5 features and the following code structure:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;delCursor = arcpy.da.UpdateCursor(fc, field)&lt;BR /&gt;for row in delCursor:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&amp;nbsp;&lt;SPAN&gt;testIfRowNeedsToBeDeleted(..):&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;delCursor.deleteRow() # messes with the number of elements in the loop!!&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I guarantee that the correct features are deleted when I delete features with 'early' OBJECTIDs out of the list, as after the first deletion, the number of elements in the field is already not the same as the cursor's number.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How is this handled internally?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;* * *&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the end, I just need to delete specific rows out of a feature class, depending on specific field values and I want to avoid any issues with the order.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My favourite would be this structure in pseudo code:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;to deleteFeatureOBJECTIDs = []&lt;/P&gt;&lt;P&gt;loop over cursor:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;if feature needs to be deleted based on&amp;nbsp;multiple field&amp;nbsp;values:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;deleteFeatureIDs.append(current feature)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;arcpy.deleteFeaturesInFC(&lt;SPAN style="background-color: #f6f6f6;"&gt;deleteFeature&lt;/SPAN&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;OBJECTID&lt;/SPAN&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;s&lt;/SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[[ I have also tried code-based creation of the SQL 'where_clause', with a string&amp;nbsp;list, but this type of search crashes ArcGIS PRO quite easily. ]]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any input welcome!&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;matt&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 25 Sep 2016 09:47:22 GMT</pubDate>
    <dc:creator>MatthiasBuehler</dc:creator>
    <dc:date>2016-09-25T09:47:22Z</dc:date>
    <item>
      <title>Deleting Features: Does cursor mess with order?</title>
      <link>https://community.esri.com/t5/python-questions/deleting-features-does-cursor-mess-with-order/m-p/574765#M45037</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;Question:&lt;/P&gt;&lt;P&gt;I have read that cursors can only be iterated forward, not in reversed order.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not if I have e.g. 5 features and the following code structure:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;delCursor = arcpy.da.UpdateCursor(fc, field)&lt;BR /&gt;for row in delCursor:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&amp;nbsp;&lt;SPAN&gt;testIfRowNeedsToBeDeleted(..):&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;delCursor.deleteRow() # messes with the number of elements in the loop!!&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I guarantee that the correct features are deleted when I delete features with 'early' OBJECTIDs out of the list, as after the first deletion, the number of elements in the field is already not the same as the cursor's number.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How is this handled internally?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;* * *&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the end, I just need to delete specific rows out of a feature class, depending on specific field values and I want to avoid any issues with the order.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My favourite would be this structure in pseudo code:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;to deleteFeatureOBJECTIDs = []&lt;/P&gt;&lt;P&gt;loop over cursor:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;if feature needs to be deleted based on&amp;nbsp;multiple field&amp;nbsp;values:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;deleteFeatureIDs.append(current feature)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;arcpy.deleteFeaturesInFC(&lt;SPAN style="background-color: #f6f6f6;"&gt;deleteFeature&lt;/SPAN&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;OBJECTID&lt;/SPAN&gt;&lt;SPAN style="background-color: #f6f6f6;"&gt;s&lt;/SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[[ I have also tried code-based creation of the SQL 'where_clause', with a string&amp;nbsp;list, but this type of search crashes ArcGIS PRO quite easily. ]]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any input welcome!&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;matt&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 25 Sep 2016 09:47:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/deleting-features-does-cursor-mess-with-order/m-p/574765#M45037</guid>
      <dc:creator>MatthiasBuehler</dc:creator>
      <dc:date>2016-09-25T09:47:22Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting Features: Does cursor mess with order?</title>
      <link>https://community.esri.com/t5/python-questions/deleting-features-does-cursor-mess-with-order/m-p/574766#M45038</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ps.&lt;/P&gt;&lt;P&gt;if possible, I'd like not to&amp;nbsp;have to operated with temp layers.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 25 Sep 2016 10:02:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/deleting-features-does-cursor-mess-with-order/m-p/574766#M45038</guid>
      <dc:creator>MatthiasBuehler</dc:creator>
      <dc:date>2016-09-25T10:02:16Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting Features: Does cursor mess with order?</title>
      <link>https://community.esri.com/t5/python-questions/deleting-features-does-cursor-mess-with-order/m-p/574767#M45039</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not quite sure what you are saying here about affecting the order.&lt;/P&gt;&lt;P&gt;If you run an update and then delete specific rows based on some criteria, the record will be deleted.&lt;/P&gt;&lt;P&gt;The row order, OID based is fairly arbitrary anyway, based on the order of creation.&lt;/P&gt;&lt;P&gt;So, if you have OIDs 1, 2, 3, 4, 5, then you delete 2 &amp;amp; 3, you will be left with OIDs 1, 4 &amp;amp; 5.&lt;/P&gt;&lt;P&gt;It will not automatically re-order or re number the remaining OIDs.&lt;/P&gt;&lt;P&gt;To do that you would have to do a copy features or something to a new table.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 25 Sep 2016 11:01:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/deleting-features-does-cursor-mess-with-order/m-p/574767#M45039</guid>
      <dc:creator>NeilAyres</dc:creator>
      <dc:date>2016-09-25T11:01:52Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting Features: Does cursor mess with order?</title>
      <link>https://community.esri.com/t5/python-questions/deleting-features-does-cursor-mess-with-order/m-p/574768#M45040</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you have to use cursors, be positive thinking &amp;nbsp;and keep those features that you want to keep and save to a new featureclass.&lt;/P&gt;&lt;P&gt;You can put this in cursor-esque&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;awl &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;3&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;4&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;5&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; dump &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;4&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; keep &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;i &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; i &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; awl &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; i &lt;SPAN class="operator token"&gt;not&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; dump&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; keep
&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;3&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;5&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;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:44:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/deleting-features-does-cursor-mess-with-order/m-p/574768#M45040</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-12T00:44:50Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting Features: Does cursor mess with order?</title>
      <link>https://community.esri.com/t5/python-questions/deleting-features-does-cursor-mess-with-order/m-p/574769#M45041</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi guys, thanks for the replies - on a sunday!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Oh - I think the key is in understanding that the OBJECTID in a FC is NOT always enumerated from 1 to n. I was under the impression this is the case. (I'm not a GIS expert)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have just tried manually deleting a feature and adding an other one manually and the result shows me that the OBJECTID of the newly drawn does not replace the last (missing) spot, but is 1 higher than the highest existing OBJECTID value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;--&amp;gt;&lt;/P&gt;&lt;P&gt;1] Can you guys confirm that arcpy handles this the same as when doing stuff manually?&lt;/P&gt;&lt;P&gt;2] If so, then the whole question would be answered by this very important detail.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks guys!&lt;/P&gt;&lt;P&gt;matt&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 25 Sep 2016 13:10:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/deleting-features-does-cursor-mess-with-order/m-p/574769#M45041</guid>
      <dc:creator>MatthiasBuehler</dc:creator>
      <dc:date>2016-09-25T13:10:49Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting Features: Does cursor mess with order?</title>
      <link>https://community.esri.com/t5/python-questions/deleting-features-does-cursor-mess-with-order/m-p/574770#M45042</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;why don't you run a comparison on your data, since you will then have a standard to compare to. &amp;nbsp;Of course, it goes without saying, one never alters an existing dataset, but uses a copy. &amp;nbsp;Storage is cheap, time is not.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 25 Sep 2016 17:31:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/deleting-features-does-cursor-mess-with-order/m-p/574770#M45042</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-09-25T17:31:51Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting Features: Does cursor mess with order?</title>
      <link>https://community.esri.com/t5/python-questions/deleting-features-does-cursor-mess-with-order/m-p/574771#M45043</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would say yes, manual vs script will handle things the same, assuming all else is equal.&lt;/P&gt;&lt;P&gt;you may want to read thru&amp;nbsp;&lt;A class="link-titled" href="https://desktop.arcgis.com/en/arcmap/latest/manage-data/tables/fundamentals-of-objectid-fields.htm" title="https://desktop.arcgis.com/en/arcmap/latest/manage-data/tables/fundamentals-of-objectid-fields.htm"&gt;Fundamentals of ObjectID fields—Help | ArcGIS for Desktop&lt;/A&gt;&amp;nbsp; to get a little better understanding or OIDs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since we don't really have control over the OID assignment, I suggest adding a unique field to store the value of the order (if that's what you are going for). &amp;nbsp;If important, you could start out by calculating the start value as the current OID value. &amp;nbsp;Then, before you delet the on record, grab the value and insert it in the "uniqid"&amp;nbsp;&amp;nbsp;field for the new record.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but as Dan mentioned, always good to compare output from manual vs script (and on a copy). &amp;nbsp;Always good to test and review, especially if this is critical and will be used "blindly" (leap of faith) in the future.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sorry not including any code...on my iPad.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 25 Sep 2016 18:38:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/deleting-features-does-cursor-mess-with-order/m-p/574771#M45043</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2016-09-25T18:38:25Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting Features: Does cursor mess with order?</title>
      <link>https://community.esri.com/t5/python-questions/deleting-features-does-cursor-mess-with-order/m-p/574772#M45044</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/54574" target="_blank"&gt;Matthias Buehler&lt;/A&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When deleting elements from a collection you have to be careful not to "cut the branch you sitting on":&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/234104_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;Source:&amp;nbsp;&lt;A class="link-titled" href="http://www.publicdomainpictures.net/pictures/10000/velka/1210-1240955295Hn8Q.jpg" title="http://www.publicdomainpictures.net/pictures/10000/velka/1210-1240955295Hn8Q.jpg" rel="nofollow noopener noreferrer" target="_blank"&gt;http://www.publicdomainpictures.net/pictures/10000/velka/1210-1240955295Hn8Q.jpg&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The cursor however, handles this correctly (as far as I know). Look at the snippet below:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;main&lt;/SPAN&gt;&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;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy

&amp;nbsp;&amp;nbsp;&amp;nbsp; fc &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;'C:\GeoNet\DeleteFeaturesPython\data.gdb\points'&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"before"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; getCount&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fc&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;with&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;da&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;UpdateCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fc&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'OID@'&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;as&lt;/SPAN&gt; curs&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; row &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; curs&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; oid&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; row&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;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; oid &lt;SPAN class="operator token"&gt;%&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;2&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&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; &lt;SPAN class="comment token"&gt;# delete even oid's&lt;/SPAN&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; curs&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;deleteRow&lt;SPAN class="punctuation token"&gt;(&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="string token"&gt;"after"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; getCount&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fc&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;


&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;getCount&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fc&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; int&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;GetCount_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fc&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;getOutput&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="punctuation token"&gt;)&lt;/SPAN&gt;


&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; __name__ &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'__main__'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; main&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;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It prints in my case:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;before 876
after 438&lt;SPAN class="line-numbers-rows"&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;&lt;/P&gt;&lt;P&gt;And looking at the attribute table before and after it has removed correctly the rows with en even ObjectID:&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/234120_pastedImage_2.png" /&gt;&amp;nbsp; &amp;nbsp;&lt;IMG class="image-3 jive-image" src="https://community.esri.com/legacyfs/online/234121_pastedImage_3.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; before &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; after&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Might be something specific with the case you are working on.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;BTW&lt;/STRONG&gt;: love your CityEngine work on&amp;nbsp;&lt;EM&gt;Independence Day: Resurgence&lt;/EM&gt;&amp;nbsp;&lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/wink.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:44:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/deleting-features-does-cursor-mess-with-order/m-p/574772#M45044</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-12T00:44:53Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting Features: Does cursor mess with order?</title>
      <link>https://community.esri.com/t5/python-questions/deleting-features-does-cursor-mess-with-order/m-p/574773#M45045</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for all the inputs, much appreciated.&lt;/P&gt;&lt;P&gt;And yes, the features I'm deleting are derived from some other features, so if the input features have changed, I have to delete the irrelevant derived features.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cool pic, btw! &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/3100"&gt;Xander Bakker&lt;/A&gt;‌&lt;/P&gt;&lt;P&gt;Thanks for the compliment!&amp;nbsp;I'm good in some things, but not so in others. Well, like all of us. &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;Did you see &lt;A href="http://livestream.com/gnomon/independence-day-cityengine"&gt;this presentation&lt;/A&gt;?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Arcpy is a new thing I'm learning for my &lt;A href="http://www.vrbn.io/"&gt;CityEngine services&lt;/A&gt;, so I'm trying to get the things I need in a&amp;nbsp;workflow prototype I'm working on for Esri Germany to work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Huge thanks!&lt;/P&gt;&lt;P&gt;Matt&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Sep 2016 07:41:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/deleting-features-does-cursor-mess-with-order/m-p/574773#M45045</guid>
      <dc:creator>MatthiasBuehler</dc:creator>
      <dc:date>2016-09-26T07:41:46Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting Features: Does cursor mess with order?</title>
      <link>https://community.esri.com/t5/python-questions/deleting-features-does-cursor-mess-with-order/m-p/574774#M45046</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/54574"&gt;Matthias Buehler&lt;/A&gt;&amp;nbsp;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you can share a bit more information and perhaps some (dummy) data, maybe I can track what is happening and see if there is something in the Python script you're using.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And yes I attended the live-seminar where you presented your work for Independence day. &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards, Xander&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Sep 2016 11:27:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/deleting-features-does-cursor-mess-with-order/m-p/574774#M45046</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2016-09-26T11:27:48Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting Features: Does cursor mess with order?</title>
      <link>https://community.esri.com/t5/python-questions/deleting-features-does-cursor-mess-with-order/m-p/574775#M45047</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you can consistently crash ArcGIS Pro by using a specific SQL WHERE clause, I suggest you contact Esri Support and get a bug logged.&amp;nbsp; Afterwards, share the bug number and information back in this post for the benefit of the community.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Whether accessing data sets through the GUI, ArcPy cursors, or some other client/API; there are multiple layers of abstraction between the tool you are interacting with and the data itself.&amp;nbsp; It is the lower levels in these layers/stacks that actually implement updates, insertions, and deletions; and this is where data integrity is implemented.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As others have commented already, "trust the cursors."&amp;nbsp; From a purely practical perspective, if&amp;nbsp;ArcPy cursors could so easily corrupt data sets, they wouldn't be around any longer.&amp;nbsp; There are few quicker ways to lose customers than having tools that corrupt data easily and consistently.&amp;nbsp; From a theoretical perspective, understanding why your first code snippet will work and not corrupt data involves learning about SQL, database engines, result sets, cursors, transactions, and other elements of databases.&amp;nbsp; If you want to avoid taking a course or cracking a textbook, there is a not-so-primer primer on &lt;A href="http://rusanu.com/2013/08/01/understanding-how-sql-server-executes-a-query/"&gt;Understanding how SQL Server executes a query&lt;/A&gt;.&amp;nbsp; Although the blog post is specific to SQL Server, the principles apply to databases in general.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Sep 2016 14:18:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/deleting-features-does-cursor-mess-with-order/m-p/574775#M45047</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2016-09-26T14:18:16Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting Features: Does cursor mess with order?</title>
      <link>https://community.esri.com/t5/python-questions/deleting-features-does-cursor-mess-with-order/m-p/574776#M45048</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Heres my code for making an SQL statement from a list with no error catching or anything:&lt;/P&gt;&lt;P&gt;I use it with lists of ObjectIDs all the time to start my cursors &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;fieldName = 'FIELD1'&lt;BR /&gt;valueList = ['Value1', 'Value2']&lt;/P&gt;&lt;P&gt;where = "%s in ('" % fieldName&lt;BR /&gt;where += "','".join(map(str, valueList)) + "')"&lt;BR /&gt;print where&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;FIELD1 in ('Value1','Value2')&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Sep 2016 15:35:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/deleting-features-does-cursor-mess-with-order/m-p/574776#M45048</guid>
      <dc:creator>LukeWebb</dc:creator>
      <dc:date>2016-09-27T15:35:00Z</dc:date>
    </item>
  </channel>
</rss>

