Hello,
I am using python notebook on ArcGIS Pro 2.8. Please see script and screenshots. I was able to get data zip file download but unable to extract data zip file. It has FGBD as another zip file inside the zip file folder. Am I missing something?? Please kindly assist as soon as possible. I am not sure which group I can post. Thank you, Alex
from arcgis.gis import GIS
# Python Standard Library Modules
from pathlib import Path, PurePath
from zipfile import ZipFile
public_data_item_id = '123'
anon_gis = GIS(username="123", password="123")
data_item = anon_gis.content.get(public_data_item_id)
data_path = Path('C:\123')
if not data_path.exists():
data_path.mkdir()
zip_path = data_path.joinpath('PAData.zip')
extract_path = data_path.joinpath('PADataDatasets')
data_item.download(save_path=data_path)
print (PurePath(zip_path))
Solved! Go to Solution.
Hello @BlakeTerhune Please see screenshots and python script. i also set it up on task scheduler. it was working running since September 2021 until stop recently. I haven't change any script and task scheduler. For some reasons, my zip file 'PaFiles.gdb' stopped working. I found out that the last time inside that zip file, it ran populated on Jan. 2022 but everything else is fine. Please advise. Thank you for your help.
from arcgis.gis import GIS
# Python Standard Library Modules
from pathlib import Path, PurePath
from zipfile import ZipFile
public_data_item_id = '123'
anon_gis = GIS(username="123", password="123")
data_item = anon_gis.content.get(public_data_item_id)
data_path = Path('C:\123')
if not data_path.exists():
data_path.mkdir()
zip_path = data_path.joinpath('PAData.zip')
extract_path = data_path.joinpath('PADataDatasets')
with ZipFile(zip_path, 'r') as zip_ref:
zip_ref.extractall(extract_path)
data_item.download(save_path=data_path)
print (PurePath(zip_path))
from pathlib import Path, PurePath
from zipfile import ZipFile
data_path = Path('C:\123\PADataDatasets\PA_Data')
if not data_path.exists():
data_path.mkdir()
zip_path = data_path.joinpath('PaFiles.gdb.zip')
extract_path = data_path.joinpath('PaFiles.gdb')
with ZipFile(zip_path, 'r') as zip_ref:
zip_ref.extractall(extract_path)
print (PurePath(zip_path))
If it was working fine, it must be an access issue. I would start by logging in to the computer running the scheduled task as the user the scheduled task is running as, then see if you can run the script inside of an IDE there. If that works, then there's a configuration issue with Windows Task Scheduler. If it doesn't work, you should be able to debug it from the IDE.
I ran it manually from task scheduler, and it is working. It seems like configuration issue with windows task. I am not sure where to narrow it down. It hasn't been changed.