<?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: Update Cursor for Deleting Rows in Hosted Layer in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/update-cursor-for-deleting-rows-in-hosted-layer/m-p/1222128#M7904</link>
    <description>&lt;P&gt;So I would need to create a list containing the FACILITYID from the JOINED_STRUCTURES_1 layer and feed that into the&amp;nbsp;&lt;STRONG&gt;FeatureLayer.delete_features()&amp;nbsp;&lt;/STRONG&gt;command as the where clause right?&lt;/P&gt;</description>
    <pubDate>Fri, 14 Oct 2022 16:39:35 GMT</pubDate>
    <dc:creator>kjseitz2</dc:creator>
    <dc:date>2022-10-14T16:39:35Z</dc:date>
    <item>
      <title>Update Cursor for Deleting Rows in Hosted Layer</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/update-cursor-for-deleting-rows-in-hosted-layer/m-p/1222119#M7902</link>
      <description>&lt;P&gt;I'm trying to delete rows in a hosted layer by searching my local layer to feed an update cursor. I'm hitting an error claiming "AttributeError: 'Polygon' object has no attribute 'FACILITYID'". Below is my current code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;arcpy.env.overwriteOutput = True

# Create GIS object
gis = GIS('https://www.arcgis.com', username, password)
print("Logged in as " + str(gis.properties.user.username))

#lyr that will be search cursored
lyrSearch = r"C:\blahblah\JOINED_STRUCTURES_1"

#Hosted Layer Item ID
fsItemId = "2e1f37aab41746afacfcf7c8534384e8" 

#lyr that will be inserted into
lyrInsert = gis.content.get(fsItemId)
#needs to point directly to the layer in the Feature Service
tableInsert = lyrInsert.layers[0].url
print("Got Feature Service")

#a list of the fields needed to be loaded
fieldNames = ['SHAPE@', 'FACILITYID', 'ADDRESS', 'Editor', 'COMMENTS', 'ADDRESS', 'CITY', 'STATE', 'ZIP', 'DISPLAYOWNERNAME', 'CROSSBORESTATUS', 'CROSSBORECOMMENT', 'REPAIRSTATUS', 'ContractorName', 'Static_FacilityID']

#Update function
uCurs = arcpy.da.UpdateCursor(tableInsert, 'FACILITYID')

#cursor for searching and then feeding uCurs

n = 0
with arcpy.da.SearchCursor(lyrSearch, fieldNames) as sCurs:
    for row in sCurs:
        if row[0].FACILITYID == sCurs:
            uCurs.deleteRow(row)
            n +=1
            continue

print("Deleted " + str(n))
print('FIN')&lt;/LI-CODE&gt;&lt;P&gt;If I remove the .FACILITYID in line 30 and just have "row[0] == sCurs:", then the script will run through, but not delete anything. Any suggestions?&lt;/P&gt;</description>
      <pubDate>Fri, 14 Oct 2022 16:27:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/update-cursor-for-deleting-rows-in-hosted-layer/m-p/1222119#M7902</guid>
      <dc:creator>kjseitz2</dc:creator>
      <dc:date>2022-10-14T16:27:03Z</dc:date>
    </item>
    <item>
      <title>Re: Update Cursor for Deleting Rows in Hosted Layer</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/update-cursor-for-deleting-rows-in-hosted-layer/m-p/1222121#M7903</link>
      <description>&lt;P&gt;Couldn't you just use &lt;STRONG&gt;FeatureLayer.delete_features() &lt;/STRONG&gt;instead? If you have a reliable method to identify your deletes, passing a list of OIDs to that method is very simple.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Oct 2022 16:33:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/update-cursor-for-deleting-rows-in-hosted-layer/m-p/1222121#M7903</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-10-14T16:33:17Z</dc:date>
    </item>
    <item>
      <title>Re: Update Cursor for Deleting Rows in Hosted Layer</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/update-cursor-for-deleting-rows-in-hosted-layer/m-p/1222128#M7904</link>
      <description>&lt;P&gt;So I would need to create a list containing the FACILITYID from the JOINED_STRUCTURES_1 layer and feed that into the&amp;nbsp;&lt;STRONG&gt;FeatureLayer.delete_features()&amp;nbsp;&lt;/STRONG&gt;command as the where clause right?&lt;/P&gt;</description>
      <pubDate>Fri, 14 Oct 2022 16:39:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/update-cursor-for-deleting-rows-in-hosted-layer/m-p/1222128#M7904</guid>
      <dc:creator>kjseitz2</dc:creator>
      <dc:date>2022-10-14T16:39:35Z</dc:date>
    </item>
    <item>
      <title>Re: Update Cursor for Deleting Rows in Hosted Layer</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/update-cursor-for-deleting-rows-in-hosted-layer/m-p/1222134#M7905</link>
      <description>&lt;P&gt;Yeah, you could create a list, but it needs to be in valid SQL, so you'd need to convert it to something you can pipe into "some_field IN('list','of','values')".&lt;/P&gt;&lt;LI-CODE lang="python"&gt;delete_where = f"""FACILITYID IN({','.join(["'" + i + "'" for i in your_list])})"""&lt;/LI-CODE&gt;&lt;P&gt;Spits out something like:&lt;/P&gt;&lt;PRE&gt;FACILITYID IN('a','list','of','values')&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Oct 2022 16:50:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/update-cursor-for-deleting-rows-in-hosted-layer/m-p/1222134#M7905</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-10-14T16:50:13Z</dc:date>
    </item>
  </channel>
</rss>

