I am uploading about 40 zip files to AGOL as shapefiles being published as feature layers using a Jupyter Notebook. Just about all of the zip files are shapefiles but I have discovered a few are actually geodatabases zipped up. Each time the program finds a gdb, it stops and I get an error. 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. Then I repeat those steps. I tried using " if arcpy.Exists" but that only checks for existence in the folder on my drive, not on AGOL. I would ideally like it to print the files that dont work but keep on chugging through.
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()