<?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: Check if a layer exists in ArcGIS Online in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/check-if-a-layer-exists-in-arcgis-online/m-p/1040667#M5814</link>
    <description>&lt;P&gt;thank you Mehdi, I had tried to do this but wasn't successful.&amp;nbsp; Its good to know I can set the data type in the code like that.&lt;/P&gt;</description>
    <pubDate>Thu, 25 Mar 2021 16:44:35 GMT</pubDate>
    <dc:creator>DryCreekEng</dc:creator>
    <dc:date>2021-03-25T16:44:35Z</dc:date>
    <item>
      <title>Check if a layer exists in ArcGIS Online</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/check-if-a-layer-exists-in-arcgis-online/m-p/1039891#M5788</link>
      <description>&lt;P&gt;I am uploading about 40 zip files to AGOL as shapefiles being published as feature layers using a Jupyter Notebook.&amp;nbsp; Just about all of the zip files are shapefiles but I have discovered a few are actually geodatabases zipped up.&amp;nbsp; Each time the program finds a gdb, it stops and I get an error.&amp;nbsp; I have to rename the folder, go into AGOL and delete ALL the layers before it that were just created, then rerun the program until it hits another gdb.&amp;nbsp; Then I repeat those steps.&amp;nbsp; I tried using " if arcpy.Exists" but that only checks for existence in the folder on my drive, not on AGOL.&amp;nbsp; I would ideally like it to print the files that dont work but keep on chugging through.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;list = []
for p in arcpy.ListFiles("*.zip"):
    list.append(p)
    print (p)    
for n in list:
    if "gdb" not in n:
        if "App" not in n:
                print (n)
                data_file_location = workspace + "\\" + n
                layer = { 'title': ('%s') % n[:-4],    'tags': 'data collection',    'type': 'Shapefile'}
                add_layer = gis.content.add(layer, data = data_file_location) 
                pub = add_layer.publish()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Mar 2021 19:04:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/check-if-a-layer-exists-in-arcgis-online/m-p/1039891#M5788</guid>
      <dc:creator>DryCreekEng</dc:creator>
      <dc:date>2021-03-23T19:04:27Z</dc:date>
    </item>
    <item>
      <title>Re: Check if a layer exists in ArcGIS Online</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/check-if-a-layer-exists-in-arcgis-online/m-p/1040001#M5789</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/356708"&gt;@DryCreekEng&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;For the file geodatabase you need to specify the type in the item properties.&lt;/P&gt;&lt;P&gt;This is a quick script I put together:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;if gdb:
    item_props = {'type':'File Geodatabase'}
elif shapefile:
    item_props = {'type':'Shapefile'}
else: 
    .....
add_item = gis.content.add(item_properties= item_props, data = path to data file)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope that helps.&lt;/P&gt;&lt;P&gt;Mehdi&lt;/P&gt;</description>
      <pubDate>Wed, 24 Mar 2021 01:51:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/check-if-a-layer-exists-in-arcgis-online/m-p/1040001#M5789</guid>
      <dc:creator>MehdiPira1</dc:creator>
      <dc:date>2021-03-24T01:51:41Z</dc:date>
    </item>
    <item>
      <title>Re: Check if a layer exists in ArcGIS Online</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/check-if-a-layer-exists-in-arcgis-online/m-p/1040022#M5790</link>
      <description>&lt;P&gt;You can use gis.content.search to check if a service is existing in AGOL or Portal.&lt;/P&gt;&lt;P&gt;have you seen this user guide:&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/python/guide/working-with-feature-layers-and-features/#Searching-the-GIS-for-feature-layers" target="_blank"&gt;https://developers.arcgis.com/python/guide/working-with-feature-layers-and-features/#Searching-the-GIS-for-feature-layers&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Mar 2021 03:56:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/check-if-a-layer-exists-in-arcgis-online/m-p/1040022#M5790</guid>
      <dc:creator>simoxu</dc:creator>
      <dc:date>2021-03-24T03:56:03Z</dc:date>
    </item>
    <item>
      <title>Re: Check if a layer exists in ArcGIS Online</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/check-if-a-layer-exists-in-arcgis-online/m-p/1040667#M5814</link>
      <description>&lt;P&gt;thank you Mehdi, I had tried to do this but wasn't successful.&amp;nbsp; Its good to know I can set the data type in the code like that.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Mar 2021 16:44:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/check-if-a-layer-exists-in-arcgis-online/m-p/1040667#M5814</guid>
      <dc:creator>DryCreekEng</dc:creator>
      <dc:date>2021-03-25T16:44:35Z</dc:date>
    </item>
    <item>
      <title>Re: Check if a layer exists in ArcGIS Online</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/check-if-a-layer-exists-in-arcgis-online/m-p/1040906#M5819</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/356708"&gt;@DryCreekEng&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Not a problem. What is the error you're getting?&lt;/P&gt;&lt;P&gt;You'd better clean up the AGOL from the published zipped files first.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Mar 2021 00:38:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/check-if-a-layer-exists-in-arcgis-online/m-p/1040906#M5819</guid>
      <dc:creator>MehdiPira1</dc:creator>
      <dc:date>2021-03-26T00:38:21Z</dc:date>
    </item>
    <item>
      <title>Re: Check if a layer exists in ArcGIS Online</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/check-if-a-layer-exists-in-arcgis-online/m-p/1041628#M5833</link>
      <description>&lt;P&gt;I get an error saying that the layer already exists in AGOL, and the code stops running.&amp;nbsp; My problem is that I run code to upload a bunch of files, and if an error occurs, the code stops.&amp;nbsp; I fix the problem, but before I can run the code again, I have to delete the files in AGOL that were uploaded prior to the error. Otherwise, I get the error saying the files already exist in AGOL. Its a pain, and I would like to use "OverwriteOutput = True" or something along the lines of "ifExists" but I havent been able to get anything to work.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Mar 2021 17:11:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/check-if-a-layer-exists-in-arcgis-online/m-p/1041628#M5833</guid>
      <dc:creator>DryCreekEng</dc:creator>
      <dc:date>2021-03-29T17:11:48Z</dc:date>
    </item>
    <item>
      <title>Re: Check if a layer exists in ArcGIS Online</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/check-if-a-layer-exists-in-arcgis-online/m-p/1042058#M5848</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/12731"&gt;@simoxu&lt;/a&gt;&amp;nbsp;for the article.&amp;nbsp; The article shows how you can check for a feature by specifying the feature's title or ID. Do you know how I could use this to recursively search for a feature as part of an if statement, and if True, then skip over the layer or replace it?&lt;/P&gt;</description>
      <pubDate>Tue, 30 Mar 2021 18:14:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/check-if-a-layer-exists-in-arcgis-online/m-p/1042058#M5848</guid>
      <dc:creator>DryCreekEng</dc:creator>
      <dc:date>2021-03-30T18:14:26Z</dc:date>
    </item>
  </channel>
</rss>

