<?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 Can someone help me fix this Automated Download script? in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/can-someone-help-me-fix-this-automated-download/m-p/839999#M3481</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;from arcgis.gis import GIS&lt;BR /&gt;#from datetime import datetime&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#Python Standard Library modules&lt;BR /&gt;from pathlib import Path&lt;BR /&gt;from zipfile import ZipFile&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;print('import complete')&lt;BR /&gt;#store the IF of the public data item being downloaded&lt;BR /&gt;data_item_id = 'a3e1fb26f38d487480299b570994ffce'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#login to ArcGIS Online&lt;BR /&gt;#user =&amp;nbsp;&lt;BR /&gt;#password = '&lt;BR /&gt;gis = GIS(username='x, password='!x')&lt;/P&gt;&lt;P&gt;print('Login successful')&lt;/P&gt;&lt;P&gt;#use API to retrieve and item object data_item&lt;BR /&gt;data_item = gis.content.get(data_item_id)&lt;/P&gt;&lt;P&gt;#if no Item with that Id, return None&lt;BR /&gt;data_item&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#download zipfile to the server's current location r'G:\Dinuba\2020\ArcGISOnline\Fire_hydrant_CSVs'&lt;BR /&gt;data_path = Path(r'G:\Dinuba\2020\ArcGISOnline\Fire_hydrant_CSVs')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#timestamp = time.strftime('%Y%m%d')&lt;BR /&gt;zip_path = data_path.joinpath('hydrant.zip') &lt;BR /&gt;extract_path = data_path.joinpath('FireHydrants')&lt;BR /&gt;data_item.download(save_path=data_path)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;#extract zipfile, make list of contents in directory&lt;BR /&gt;zip_file = ZipFile(zip_path)&lt;BR /&gt;zip_file.extractall(path=extract_path)&lt;BR /&gt;list(file.name for file in extract_path.glob('*'))&lt;BR /&gt;print('Download Complete')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the error I keep getting.&amp;nbsp; I don't understand what I am doing wrong.&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;Traceback (most recent call last):&lt;BR /&gt; &amp;nbsp;&amp;nbsp;File "C:/Users/brossi/Desktop/download_data.py", line 34, in &amp;lt;module&amp;gt;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;zip_file = ZipFile(zip_path)&lt;BR /&gt; &amp;nbsp;&amp;nbsp;File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\zipfile.py", line 1113, in __init__&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;self.fp = io.open(file, filemode)&lt;BR /&gt; FileNotFoundError: [Errno 2] No such file or directory: 'G:\\Dinuba\x820\\ArcGISOnline\\Fire_hydrant_CSVs\\hydrant20200720'&lt;BR /&gt; &amp;gt;&amp;gt;&amp;gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;I disabled the timestamp because I just wanted to get the script working but for some reason no matter what I do it keeps coming up with&amp;nbsp; this.&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 20 Jul 2020 22:17:50 GMT</pubDate>
    <dc:creator>DinubaAGOLAdmin</dc:creator>
    <dc:date>2020-07-20T22:17:50Z</dc:date>
    <item>
      <title>Can someone help me fix this Automated Download script?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/can-someone-help-me-fix-this-automated-download/m-p/839999#M3481</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;from arcgis.gis import GIS&lt;BR /&gt;#from datetime import datetime&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#Python Standard Library modules&lt;BR /&gt;from pathlib import Path&lt;BR /&gt;from zipfile import ZipFile&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;print('import complete')&lt;BR /&gt;#store the IF of the public data item being downloaded&lt;BR /&gt;data_item_id = 'a3e1fb26f38d487480299b570994ffce'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#login to ArcGIS Online&lt;BR /&gt;#user =&amp;nbsp;&lt;BR /&gt;#password = '&lt;BR /&gt;gis = GIS(username='x, password='!x')&lt;/P&gt;&lt;P&gt;print('Login successful')&lt;/P&gt;&lt;P&gt;#use API to retrieve and item object data_item&lt;BR /&gt;data_item = gis.content.get(data_item_id)&lt;/P&gt;&lt;P&gt;#if no Item with that Id, return None&lt;BR /&gt;data_item&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#download zipfile to the server's current location r'G:\Dinuba\2020\ArcGISOnline\Fire_hydrant_CSVs'&lt;BR /&gt;data_path = Path(r'G:\Dinuba\2020\ArcGISOnline\Fire_hydrant_CSVs')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#timestamp = time.strftime('%Y%m%d')&lt;BR /&gt;zip_path = data_path.joinpath('hydrant.zip') &lt;BR /&gt;extract_path = data_path.joinpath('FireHydrants')&lt;BR /&gt;data_item.download(save_path=data_path)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;#extract zipfile, make list of contents in directory&lt;BR /&gt;zip_file = ZipFile(zip_path)&lt;BR /&gt;zip_file.extractall(path=extract_path)&lt;BR /&gt;list(file.name for file in extract_path.glob('*'))&lt;BR /&gt;print('Download Complete')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the error I keep getting.&amp;nbsp; I don't understand what I am doing wrong.&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;Traceback (most recent call last):&lt;BR /&gt; &amp;nbsp;&amp;nbsp;File "C:/Users/brossi/Desktop/download_data.py", line 34, in &amp;lt;module&amp;gt;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;zip_file = ZipFile(zip_path)&lt;BR /&gt; &amp;nbsp;&amp;nbsp;File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\zipfile.py", line 1113, in __init__&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;self.fp = io.open(file, filemode)&lt;BR /&gt; FileNotFoundError: [Errno 2] No such file or directory: 'G:\\Dinuba\x820\\ArcGISOnline\\Fire_hydrant_CSVs\\hydrant20200720'&lt;BR /&gt; &amp;gt;&amp;gt;&amp;gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;I disabled the timestamp because I just wanted to get the script working but for some reason no matter what I do it keeps coming up with&amp;nbsp; this.&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jul 2020 22:17:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/can-someone-help-me-fix-this-automated-download/m-p/839999#M3481</guid>
      <dc:creator>DinubaAGOLAdmin</dc:creator>
      <dc:date>2020-07-20T22:17:50Z</dc:date>
    </item>
    <item>
      <title>Re: Can someone help me fix this Automated Download script?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/can-someone-help-me-fix-this-automated-download/m-p/840000#M3482</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey &lt;A href="https://community.esri.com/migrated-users/305940"&gt;DinubaAGOL Admin&lt;/A&gt;‌,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'd personally do a print on the zip_path variable after you create it. It looks as though the path is misinterpreting the backslashes and as such it can't find the folder path. You can see in your error the path has only one backslash around the 2020 part and has changed it: G:\\Dinuba&lt;SPAN style="color: #ff0000;"&gt;\x820&lt;/SPAN&gt;\\ArcGISOnline\\Fire_hydrant_CSVs\\hydrant20200720&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can further test this by hardcoding the path here:&lt;/P&gt;&lt;P&gt;zip_file = ZipFile(zip_path)&lt;/P&gt;&lt;P&gt;to&lt;/P&gt;&lt;P&gt;zip_file = ZipFile(r'G:\Dinuba\2020\ArcGISOnline\Fire_hydrant_CSVs\firehydrant.zip')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF this is where the error is you could try using os.path.join. I haven't personally used pathlib so I'm not sure of its capabilities or limitations: &lt;A class="link-titled" href="https://www.geeksforgeeks.org/python-os-path-join-method/" title="https://www.geeksforgeeks.org/python-os-path-join-method/"&gt;Python | os.path.join() method - GeeksforGeeks&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Happy to discuss more.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ben&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;&lt;EM&gt;If this answer was helpful please mark it as helpful. If this answer solved your question please mark it as the answer to help others who have the same question.&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jul 2020 22:58:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/can-someone-help-me-fix-this-automated-download/m-p/840000#M3482</guid>
      <dc:creator>BenTurrell</dc:creator>
      <dc:date>2020-07-20T22:58:29Z</dc:date>
    </item>
    <item>
      <title>Re: Can someone help me fix this Automated Download script?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/can-someone-help-me-fix-this-automated-download/m-p/840001#M3483</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/305940" target="_blank"&gt;DinubaAGOL Admin&lt;/A&gt;‌ I've used the following to download and extract a File Geodatabase from AGOL:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;from&lt;/SPAN&gt; arcgis&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;gis &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; GIS
&lt;SPAN class="keyword token"&gt;from&lt;/SPAN&gt; zipfile &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; ZipFile

&lt;SPAN class="comment token"&gt;# Variables&lt;/SPAN&gt;
portal &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'https://www.arcgis.com'&lt;/SPAN&gt;
username &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'jskinner_CountySandbox'&lt;/SPAN&gt;
password &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'*****'&lt;/SPAN&gt;
itemID &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'492e91060dcd4080be22b4d967655004'&lt;/SPAN&gt;
exportFolder &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"C:\temp"&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# Connect to portal&lt;/SPAN&gt;
gis &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; GIS&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;portal&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; username&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; password&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# Get item&lt;/SPAN&gt;
item &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; gis&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;content&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;get&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;itemID&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# Export hosted feature service to FGD, and downlaod&lt;/SPAN&gt;
export_name &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"export_"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; item&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;title
result_item &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; item&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;export&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;export_name&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'File Geodatabase'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; wait&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token boolean"&gt;True&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Exported: {}"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;result_item&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
download_result &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; result_item&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;download&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;exportFolder&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Saved to: {}"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;download_result&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
result_item&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;delete&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Deleted result"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# Extract zip file&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;with&lt;/SPAN&gt; ZipFile&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;download_result&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'r'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; zipObj&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
   &lt;SPAN class="comment token"&gt;# Extract all the contents of zip file in current directory&lt;/SPAN&gt;
   zipObj&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;extractall&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;exportFolder&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
   &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Unzipped {0}"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;download_result&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 10:14:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/can-someone-help-me-fix-this-automated-download/m-p/840001#M3483</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-12T10:14:33Z</dc:date>
    </item>
  </channel>
</rss>

