I have a stand-alone Python script to download a zipped shapefile from an FTP site and upload to ArcGIS Online update an existing hosted feature service. Here's the simplified version --
#Set folder to download to
folder = 'C:\\myftpdownloads\\'
out_path = os.path.join(folder)
#FTP logon
ftp = FTP('ftp.myftp.com')
ftp.login('FTPusername', 'FTPpassword')
#Get a list of all files in the folder - for simplicity, let's pretend there is only ever 1 zip file there
files = ftp.nlst()
#Loop through the files to download
for zipfile in files:
with open(os.path.join(out_path, zipfile), 'wb') as local_file:
ftp.retrbinary('RETR '+ zipfile, local_file.write)
#Upload and update existing hosted feature service in ArcGIS Online
gis = GIS("https://arcgis.com/", "AGOUser", "AGOpassword")
item = gis.content.get('123456789mycontentid987654321')
# Call the update method to replace/overwrite it with the zip file from disk
item.update({}, zipfile)
# Update hosted feature layer
# Make sure to uncheck editing in Settings
item.publish(overwrite=True,file_type='shapefile')
I want to migrate this to an ArcGIS Online Notebook so that it can be scheduled and without having a dedicated machine running ArcGIS Pro and always on.
I see good articles on Uploading datasets to use with ArcPy, Using ArcPy in ArcGIS Notebooks, and Attempting to Upload Files to ArcGIS Notebooks Programmatically -- but I can't find the exact right tutorial or post that puts it all together...
I need to programmatically download from an FTP site and upload directly ArcGIS Notebook.
Would anyone have ideas? Is this even possible?