<?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: Unzip in Python Script in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/unzip-in-python-script/m-p/568477#M44534</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I want to create a ESRI tool using python scrips to:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1) Unzip a txt file that is inside a zipped file. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2) I would like to save the txt as a csv removing the first and last rows (would like to make these part of the name or metadata)&amp;nbsp; the first row is the date created and the last row is file info.&amp;nbsp; The column headder is the second row. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3) There are 2 columns I would like to delete&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;4)Then I need to change the column headings to remove the spaces and match the fields names as I would like to geocode them.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;5) I need to concatenate several fields to create a single address field for the geocode. My address locator that I created uses a single address field with Zip. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;6) Geocode the csv with my created Address Locator to my master address point file.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is this possible?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 04 Sep 2013 18:34:11 GMT</pubDate>
    <dc:creator>KATIEATKINSON</dc:creator>
    <dc:date>2013-09-04T18:34:11Z</dc:date>
    <item>
      <title>Unzip in Python Script</title>
      <link>https://community.esri.com/t5/python-questions/unzip-in-python-script/m-p/568467#M44524</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am trying to unzip a Zip file in a Windows directory.&amp;nbsp; Does anyone know the commands to do this.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;the Zipfile library is too confusing for me.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Feb 2011 16:57:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/unzip-in-python-script/m-p/568467#M44524</guid>
      <dc:creator>DarrenClay</dc:creator>
      <dc:date>2011-02-16T16:57:16Z</dc:date>
    </item>
    <item>
      <title>Re: Unzip in Python Script</title>
      <link>https://community.esri.com/t5/python-questions/unzip-in-python-script/m-p/568468#M44525</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import zipfile

zip = zipfile.ZipFile(r'c:\my.zip')
zip.extractall(r'c:\output')
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;This will extract the contents of my.zip to c:\output&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:29:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/unzip-in-python-script/m-p/568468#M44525</guid>
      <dc:creator>JasonScheirer</dc:creator>
      <dc:date>2021-12-12T00:29:19Z</dc:date>
    </item>
    <item>
      <title>Re: Unzip in Python Script</title>
      <link>https://community.esri.com/t5/python-questions/unzip-in-python-script/m-p/568469#M44526</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def zip_directory_to_zipfile(directory, out_zipfile):

&amp;nbsp;&amp;nbsp;&amp;nbsp; out_zip = zipfile.ZipFile(out_zipfile, 'w')

&amp;nbsp;&amp;nbsp;&amp;nbsp; for (dirpath, dirnames, filenames) in os.walk(directory):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for file in filenames:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; path_in_zip = os.path.join(os.path.relpath(dirpath, 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lib_dir), 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; file)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if os.path.split(path_in_zip)[0] == ".":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; path_in_zip = os.path.split(path_in_zip)[1]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; out_zip.write(os.path.join(dirpath, file), path_in_zip)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:29:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/unzip-in-python-script/m-p/568469#M44526</guid>
      <dc:creator>JasonScheirer</dc:creator>
      <dc:date>2021-12-12T00:29:22Z</dc:date>
    </item>
    <item>
      <title>Re: Unzip in Python Script</title>
      <link>https://community.esri.com/t5/python-questions/unzip-in-python-script/m-p/568470#M44527</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I think you are onto somthing, but I need a little help integrating it into the arcpy module.&amp;nbsp; What would it be like if we know that the dirpath is the arcpy.env.workspace is the current one.&amp;nbsp; Then we want to make everything in that dirpath zipped up.&amp;nbsp; Would it make the script shorter somehow?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Not really.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def zip_directory_to_zipfile(out_zipfile):

&amp;nbsp;&amp;nbsp;&amp;nbsp; out_zip = zipfile.ZipFile(out_zipfile, 'w')
 
&amp;nbsp;&amp;nbsp;&amp;nbsp; for (dirpath, dirnames, filenames) in os.walk(arcpy.env.workspace):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for file in filenames:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; path_in_zip = os.path.join(os.path.relpath(dirpath, 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lib_dir), 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; file)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if os.path.split(path_in_zip)[0] == ".":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; path_in_zip = os.path.split(path_in_zip)[1]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; out_zip.write(os.path.join(dirpath, file), path_in_zip)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:29:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/unzip-in-python-script/m-p/568470#M44527</guid>
      <dc:creator>JasonScheirer</dc:creator>
      <dc:date>2021-12-12T00:29:25Z</dc:date>
    </item>
    <item>
      <title>Re: Unzip in Python Script</title>
      <link>https://community.esri.com/t5/python-questions/unzip-in-python-script/m-p/568471#M44528</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If that's what you want, then a .zip file is not the appropriate distribution mechanism -- workspaces can be more than a directory, such as an .sde file or file geodatabase, and a dataset living in any non-directory workspace would not be included in the zip. In fact, it would be hard to even include .shp files in the directory tree because ListDatasets would return each one without the .shp extension.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For what you want, use a Map or Layer package from desktop to consolidate your data.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Feb 2011 22:49:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/unzip-in-python-script/m-p/568471#M44528</guid>
      <dc:creator>JasonScheirer</dc:creator>
      <dc:date>2011-02-17T22:49:25Z</dc:date>
    </item>
    <item>
      <title>Re: Unzip in Python Script</title>
      <link>https://community.esri.com/t5/python-questions/unzip-in-python-script/m-p/568472#M44529</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//0017000000q4000000.htm"&gt;The tool documentation&lt;/A&gt;&lt;SPAN&gt; includes examples.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Feb 2011 20:29:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/unzip-in-python-script/m-p/568472#M44529</guid>
      <dc:creator>JasonScheirer</dc:creator>
      <dc:date>2011-02-25T20:29:40Z</dc:date>
    </item>
    <item>
      <title>Re: Unzip in Python Script</title>
      <link>https://community.esri.com/t5/python-questions/unzip-in-python-script/m-p/568473#M44530</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Jason,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am using your code to zip up a single file in a directory. However the zip file and the original file(*.txt) are the same size (i.e. 0% compression) what would cause this and what do I need to look for to correct it.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Nov 2011 21:28:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/unzip-in-python-script/m-p/568473#M44530</guid>
      <dc:creator>ScottBlankenbeckler</dc:creator>
      <dc:date>2011-11-30T21:28:10Z</dc:date>
    </item>
    <item>
      <title>Re: Unzip in Python Script</title>
      <link>https://community.esri.com/t5/python-questions/unzip-in-python-script/m-p/568474#M44531</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Try this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;out_zip = zipfile.ZipFile(out_zipfile, 'w', zipfile.ZIP_DEFLATED)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Nov 2011 22:22:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/unzip-in-python-script/m-p/568474#M44531</guid>
      <dc:creator>JasonScheirer</dc:creator>
      <dc:date>2011-11-30T22:22:13Z</dc:date>
    </item>
    <item>
      <title>Re: Unzip in Python Script</title>
      <link>https://community.esri.com/t5/python-questions/unzip-in-python-script/m-p/568475#M44532</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;That fixed it. Much thanks.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;New problem. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any way to set it up so that it creates a split zip file of 5MB max size.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;i.e. the original file is just over 10.7MB using the code above but my email server will only allow a 10MB file. If I can split the file into a split zip of 5MB parts I can send it as two emails.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Dec 2011 12:28:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/unzip-in-python-script/m-p/568475#M44532</guid>
      <dc:creator>ScottBlankenbeckler</dc:creator>
      <dc:date>2011-12-01T12:28:38Z</dc:date>
    </item>
    <item>
      <title>Re: Unzip in Python Script</title>
      <link>https://community.esri.com/t5/python-questions/unzip-in-python-script/m-p/568476#M44533</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;That fixed it. Much thanks.&lt;BR /&gt;&lt;BR /&gt;New problem. &lt;BR /&gt;&lt;BR /&gt;Any way to set it up so that it creates a split zip file of 5MB max size.&lt;BR /&gt;i.e. the original file is just over 10.7MB using the code above but my email server will only allow a 10MB file. If I can split the file into a split zip of 5MB parts I can send it as two emails.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a simple model for Unzip a zip folder and get it's features. But I can not get extracted features. What is wrong in my model?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Jan 2013 07:04:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/unzip-in-python-script/m-p/568476#M44533</guid>
      <dc:creator>meriyalootka</dc:creator>
      <dc:date>2013-01-25T07:04:40Z</dc:date>
    </item>
    <item>
      <title>Re: Unzip in Python Script</title>
      <link>https://community.esri.com/t5/python-questions/unzip-in-python-script/m-p/568477#M44534</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I want to create a ESRI tool using python scrips to:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1) Unzip a txt file that is inside a zipped file. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2) I would like to save the txt as a csv removing the first and last rows (would like to make these part of the name or metadata)&amp;nbsp; the first row is the date created and the last row is file info.&amp;nbsp; The column headder is the second row. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3) There are 2 columns I would like to delete&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;4)Then I need to change the column headings to remove the spaces and match the fields names as I would like to geocode them.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;5) I need to concatenate several fields to create a single address field for the geocode. My address locator that I created uses a single address field with Zip. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;6) Geocode the csv with my created Address Locator to my master address point file.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is this possible?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Sep 2013 18:34:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/unzip-in-python-script/m-p/568477#M44534</guid>
      <dc:creator>KATIEATKINSON</dc:creator>
      <dc:date>2013-09-04T18:34:11Z</dc:date>
    </item>
  </channel>
</rss>

