<?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: Does anyone have a python API recipe for deleting features in an ArcGIS Online hosted feature layer? I'm specifically looking to clear out all the in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/does-anyone-have-a-python-api-recipe-for-deleting/m-p/1077736#M6340</link>
    <description>&lt;P&gt;Hi All.&lt;BR /&gt;&lt;BR /&gt;Does anyone have any guide if I want to delete using multiple clauses? Like for example, I want to delete rows where column A is not 'abc' and column B is not 'def'.&lt;BR /&gt;&lt;BR /&gt;Thank you.&lt;/P&gt;</description>
    <pubDate>Mon, 12 Jul 2021 09:58:47 GMT</pubDate>
    <dc:creator>MuhammadNaufalIhsan</dc:creator>
    <dc:date>2021-07-12T09:58:47Z</dc:date>
    <item>
      <title>Does anyone have a python API recipe for deleting features in an ArcGIS Online hosted feature layer? I'm specifically looking to clear out all the features in several layers.</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/does-anyone-have-a-python-api-recipe-for-deleting/m-p/826058#M3010</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;We have several emergency operation layers that we want to clear out quickly before an event. We will use juniper to share it with our staff too. Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Aug 2017 18:44:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/does-anyone-have-a-python-api-recipe-for-deleting/m-p/826058#M3010</guid>
      <dc:creator>AmberLauzon</dc:creator>
      <dc:date>2017-08-03T18:44:04Z</dc:date>
    </item>
    <item>
      <title>Re: Does anyone have a python API recipe for deleting features in an ArcGIS Online hosted feature layer? I'm specifically looking to clear out all the features in several layers.</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/does-anyone-have-a-python-api-recipe-for-deleting/m-p/826059#M3011</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Although this is not a full recipe, here is the snippet:&lt;/P&gt;&lt;P&gt;You can delete features by calling &lt;A href="http://esri.github.io/arcgis-python-api/apidoc/html/arcgis.features.toc.html#arcgis.features.FeatureLayer.delete_features" rel="nofollow noopener noreferrer" target="_blank"&gt;delete_features()&amp;nbsp;&lt;/A&gt;method on your FeatureLayer object like shown below:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;feature_layer_item &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; gis&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;content&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;search&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"your search criteria"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&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;
flayers &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; feature_layer_item&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;layers

flayer &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; flayers&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;
flayer&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;delete_features&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;where&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"objectid &amp;gt; 0"&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;P&gt;You can specify any other query to selectively delete some features. Alternately, if you want to delete call, then call the&amp;nbsp;&lt;STRONG&gt;truncate()&lt;/STRONG&gt; method on the FeatureLayerManager&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;flayer&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;manager&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;truncate&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Truncate will delete all features and reset the objectid or fid count back to 0. &lt;A href="http://esri.github.io/arcgis-python-api/apidoc/html/arcgis.features.managers.html?highlight=truncate#arcgis.features.managers.FeatureLayerManager.truncate" rel="nofollow noopener noreferrer" target="_blank"&gt;Help for truncate&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 09:56:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/does-anyone-have-a-python-api-recipe-for-deleting/m-p/826059#M3011</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-12T09:56:20Z</dc:date>
    </item>
    <item>
      <title>Re: Does anyone have a python API recipe for deleting features in an ArcGIS Online hosted feature layer? I'm specifically looking to clear out all the features in several layers.</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/does-anyone-have-a-python-api-recipe-for-deleting/m-p/826060#M3012</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you! Just what I needed!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Aug 2017 18:01:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/does-anyone-have-a-python-api-recipe-for-deleting/m-p/826060#M3012</guid>
      <dc:creator>AmberLauzon</dc:creator>
      <dc:date>2017-08-04T18:01:05Z</dc:date>
    </item>
    <item>
      <title>Re: Does anyone have a python API recipe for deleting features in an ArcGIS Online hosted feature layer? I'm specifically looking to clear out all the features in several layers.</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/does-anyone-have-a-python-api-recipe-for-deleting/m-p/826061#M3013</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One caveat, Truncate is not yet supported on ArcGIS Enterprise, it works for ArcGIS Online though.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Aug 2017 22:14:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/does-anyone-have-a-python-api-recipe-for-deleting/m-p/826061#M3013</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2017-08-04T22:14:35Z</dc:date>
    </item>
    <item>
      <title>Re: Does anyone have a python API recipe for deleting features in an ArcGIS Online hosted feature layer? I'm specifically looking to clear out all the features in several layers.</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/does-anyone-have-a-python-api-recipe-for-deleting/m-p/826062#M3014</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Pardon my inexperience, but I am trying to install the py for api package and I cannot using ArcGIS Pro 1.4, do you have any suggestions? The "Updates" and "Add" tabs are blank too...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/365984_error.JPG" style="width: 620px; height: 423px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Aug 2017 16:08:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/does-anyone-have-a-python-api-recipe-for-deleting/m-p/826062#M3014</guid>
      <dc:creator>AmberLauzon</dc:creator>
      <dc:date>2017-08-07T16:08:57Z</dc:date>
    </item>
    <item>
      <title>Re: Does anyone have a python API recipe for deleting features in an ArcGIS Online hosted feature layer? I'm specifically looking to clear out all the features in several layers.</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/does-anyone-have-a-python-api-recipe-for-deleting/m-p/826063#M3015</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One more caveat: looks like truncate doesn't work if sync is enabled on the dataset.&lt;/P&gt;&lt;P&gt;Not much of a problem though as the delete features seems to work fine and reasonably quickly.&lt;/P&gt;&lt;PRE class="" style="color: #000000; background: #f5f2f0; border: 0px; margin: 0.5em 0px; padding: 1em 1em 1em 3.8em;"&gt;&lt;CODE style="border: 0px; font-weight: inherit;"&gt;flayer&lt;SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;"&gt;.&lt;/SPAN&gt;delete_features&lt;SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;"&gt;(&lt;/SPAN&gt;where&lt;SPAN class="" style="color: #a67f59; background: rgba(255, 255, 255, 0.5); border: 0px; font-weight: inherit;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="" style="color: #669900; border: 0px; font-weight: inherit;"&gt;"objectid &amp;gt; 0"&lt;/SPAN&gt;&lt;SPAN class="" style="color: #999999; border: 0px; font-weight: inherit;"&gt;)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Oct 2017 09:32:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/does-anyone-have-a-python-api-recipe-for-deleting/m-p/826063#M3015</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2017-10-25T09:32:07Z</dc:date>
    </item>
    <item>
      <title>Re: Does anyone have a python API recipe for deleting features in an ArcGIS Online hosted feature layer? I'm specifically looking to clear out all the features in several layers.</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/does-anyone-have-a-python-api-recipe-for-deleting/m-p/826064#M3016</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/265535"&gt;Amber Lauzon&lt;/A&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you mark &lt;A href="https://community.esri.com/migrated-users/45514"&gt;Atma Mani&lt;/A&gt;&amp;nbsp;'s post as the correct answer please? This will help other users to quickly find the correct solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Oct 2017 11:44:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/does-anyone-have-a-python-api-recipe-for-deleting/m-p/826064#M3016</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2017-10-25T11:44:43Z</dc:date>
    </item>
    <item>
      <title>Re: Does anyone have a python API recipe for deleting features in an ArcGIS Online hosted feature layer? I'm specifically looking to clear out all the features in several layers.</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/does-anyone-have-a-python-api-recipe-for-deleting/m-p/826065#M3017</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I used the sample that &lt;A href="https://community.esri.com/migrated-users/45514" target="_blank"&gt;Atma Mani&lt;/A&gt;‌ provided and created a small script to delete features from a Hosted Feature Service in AGOL that has multiple sub-layers.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; os
&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; json
&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcgis
&lt;SPAN class="keyword token"&gt;from&lt;/SPAN&gt; arcgis&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;gis &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; GIS
&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcgis&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;features

layerName &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'title:Your Layer Name'&lt;/SPAN&gt;
maxLayerAmount &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;10&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# number of sublayers&lt;/SPAN&gt;

agolURL &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2F" target="_blank"&gt;https://&lt;/A&gt;&lt;SPAN&gt;&amp;lt;your org&amp;gt;.maps.arcgis.com"&lt;/SPAN&gt;&lt;/SPAN&gt;
agolUN &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"&amp;lt;Your UserName&amp;gt;"&lt;/SPAN&gt;
agolPass &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"&amp;lt;Your Password&amp;gt;"&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# connect to your GIS&lt;/SPAN&gt;
gis &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; GIS&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;agolURL&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; agolUN&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; agolPass&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
 
layerCount &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;while&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;layerCount &lt;SPAN class="operator token"&gt;&amp;lt;&lt;/SPAN&gt; maxLayerAmount&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; layerCount &lt;SPAN class="operator token"&gt;+=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; feature_layer_item &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; gis&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;content&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;search&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;layerName&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; item_type &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'Feature Service'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &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; flayers &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; feature_layer_item&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;layers
&amp;nbsp;&amp;nbsp;&amp;nbsp; flayer &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; flayers&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;layerCount&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="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Layer ID: "&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; str&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;layerCount&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;" Layer Name: "&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; flayer&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;properties&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;name&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; flayer&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;delete_features&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;where&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"objectid &amp;gt; 0"&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;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I also added some logging to display the name of the layers as it loops through them.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The logging looks something like this:&amp;nbsp;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;Layer ID: 0 Layer Name: Point Layer
Layer ID: 1 Layer Name: Line Layer
Layer ID: 2 Layer Name: Polygon Layer&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am still new to Python, so if there are any suggestions/comments, please let me know!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 09:56:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/does-anyone-have-a-python-api-recipe-for-deleting/m-p/826065#M3017</guid>
      <dc:creator>ChristopherSchreiber</dc:creator>
      <dc:date>2021-12-12T09:56:23Z</dc:date>
    </item>
    <item>
      <title>Re: Does anyone have a python API recipe for deleting features in an ArcGIS Online hosted feature layer? I'm specifically looking to clear out all the features in several layers.</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/does-anyone-have-a-python-api-recipe-for-deleting/m-p/826066#M3018</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;from&lt;/SPAN&gt; arcgis&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;gis &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; GIS

gis &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; GIS&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"https://site.maps.arcgis.com"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"username"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"password"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

feature_layer_item &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; gis&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;content&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;search&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"&amp;lt;item-id&amp;gt;"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&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;
flayers &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; feature_layer_item&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;layers

flayer &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; flayers&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="comment token"&gt;#count = flayer.query(return_count_only=true)&lt;/SPAN&gt;

max_objid &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; flayer&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;query&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;out_statistics&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"statisticType"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"MAX"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"onStatisticField"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"OBJECTID"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"outStatisticFieldName"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"MAX_OBJ"&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; return_geometry&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token boolean"&gt;False&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
maxoid &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; max_objid&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;features&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;attributes&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'MAX_OBJ'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;#delete in steps of 20000 or more, in case the dataset is large&lt;/SPAN&gt;

i &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;
step &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;20000&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;#replace maxoid with count if attempting to delete features based on feature count&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;while&lt;/SPAN&gt; i &lt;SPAN class="operator token"&gt;&amp;lt;=&lt;/SPAN&gt; maxoid&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    i &lt;SPAN class="operator token"&gt;+=&lt;/SPAN&gt; step
    flayer&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;delete_features&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;where&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;f&lt;SPAN class="string token"&gt;"OBJECTID &amp;lt;= {i}"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;i&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;#if using for loop&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;#for i in range(1,20000,maxoid):&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Feature Layer was truncated"&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;/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;Use this script in combination of @&lt;STRONG style="background-color: #ffffff; border: 0px; font-weight: bold; font-size: 12.6px;"&gt;&lt;A _jive_internal="true" class="" data-avatarid="-1" data-userid="154948" data-username="sch7712" href="https://community.esri.com/people/sch7712" style="color: #287433; border: 0px; font-weight: inherit; text-decoration: none; font-size: 1.1em; padding: 0px 3px 0px 0px;" target="_blank"&gt;Christopher Schreibe&lt;/A&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 13.86px;"&gt;script&lt;/SPAN&gt;&amp;nbsp;in-case there are other dependencies in your feature layer like sync capability and relationships.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://esri.github.io/arcgis-python-api/apidoc/html/arcgis.features.toc.html?highlight=query#arcgis.features.FeatureLayer.query" rel="nofollow noopener noreferrer" target="_blank"&gt;ArcGIS Feature Layer query out_statistics&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Imtiaz&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 09:56:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/does-anyone-have-a-python-api-recipe-for-deleting/m-p/826066#M3018</guid>
      <dc:creator>ImtiazSyed</dc:creator>
      <dc:date>2021-12-12T09:56:26Z</dc:date>
    </item>
    <item>
      <title>Re: Does anyone have a python API recipe for deleting features in an ArcGIS Online hosted feature layer? I'm specifically looking to clear out all the features in several layers.</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/does-anyone-have-a-python-api-recipe-for-deleting/m-p/826067#M3019</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks that worked perfectly for me, the only change I had to make was to change OBJECTID to OID because it was throwing up an error.&lt;/P&gt;&lt;P&gt;max_objid = flayer.query(out_statistics=[{"statisticType":"MAX","onStatisticField":"OID","outStatisticFieldName":"MAX_OBJ"}], return_geometry=False)&lt;BR /&gt;maxoid = max_objid.features[0].attributes['MAX_OBJ']&lt;/P&gt;&lt;P&gt;#delete in steps of 20000 or more, in case the dataset is large&lt;/P&gt;&lt;P&gt;i = 0&lt;BR /&gt;step = 20000&lt;/P&gt;&lt;P&gt;#replace maxoid with count if attempting to delete features based on feature count&lt;BR /&gt;while i &amp;lt;= maxoid:&lt;BR /&gt; i += step&lt;BR /&gt; flayer.delete_features(where=f"OID&amp;lt;= {i}")&lt;BR /&gt; print(i)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Apr 2020 18:39:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/does-anyone-have-a-python-api-recipe-for-deleting/m-p/826067#M3019</guid>
      <dc:creator>RoryBennison</dc:creator>
      <dc:date>2020-04-28T18:39:12Z</dc:date>
    </item>
    <item>
      <title>Re: Does anyone have a python API recipe for deleting features in an ArcGIS Online hosted feature layer? I'm specifically looking to clear out all the</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/does-anyone-have-a-python-api-recipe-for-deleting/m-p/1077736#M6340</link>
      <description>&lt;P&gt;Hi All.&lt;BR /&gt;&lt;BR /&gt;Does anyone have any guide if I want to delete using multiple clauses? Like for example, I want to delete rows where column A is not 'abc' and column B is not 'def'.&lt;BR /&gt;&lt;BR /&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jul 2021 09:58:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/does-anyone-have-a-python-api-recipe-for-deleting/m-p/1077736#M6340</guid>
      <dc:creator>MuhammadNaufalIhsan</dc:creator>
      <dc:date>2021-07-12T09:58:47Z</dc:date>
    </item>
  </channel>
</rss>

