{"id":7738,"date":"2025-04-15T06:40:03","date_gmt":"2025-04-15T06:40:03","guid":{"rendered":"https:\/\/ubiq.co\/tech-blog\/?p=7738"},"modified":"2026-01-20T10:21:51","modified_gmt":"2026-01-20T10:21:51","slug":"how-to-work-with-zip-files-in-python","status":"publish","type":"post","link":"https:\/\/ubiq.co\/tech-blog\/how-to-work-with-zip-files-in-python\/","title":{"rendered":"How to Work With ZIP Files in Python"},"content":{"rendered":"\n<p>Often Python developers need to work with zip files in Python. Zip files are commonly used by system administrators and software developers to compress many files and directories into a single zip file. It is great for archiving and compressing files, and saving space. You can compress and extract zip files without loss of data. They are easy to transfer as well as store. Generally, people compress and extract zip files using terminal commands. But sometimes, you may need to work with zip file in Python, in your website or web application. In this article, we will learn how to create, open, read, extract zip files. We will also learn how to add files to zip as well as get meta information about zip files.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-work-with-zip-files-in-python\/#Why_Zip_Files_in_Python\" >Why Zip Files in Python<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-work-with-zip-files-in-python\/#Zipfile_Python_Module\" >Zipfile Python Module<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-work-with-zip-files-in-python\/#How_to_Work_With_Zip_Files_in_Python\" >How to Work With Zip Files in Python<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-work-with-zip-files-in-python\/#How_to_Create_Zip_File_in_Python\" >How to Create Zip File in Python<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-work-with-zip-files-in-python\/#How_to_Read_Zip_File_Without_Opening\" >How to Read Zip File Without Opening<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-work-with-zip-files-in-python\/#How_to_Extract_Zip_File_in_Python\" >How to Extract Zip File in Python<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-work-with-zip-files-in-python\/#How_to_List_Zip_File_Contents\" >How to List Zip File Contents<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-work-with-zip-files-in-python\/#How_to_Add_Files_to_Zip_file\" >How to Add Files to Zip file<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-work-with-zip-files-in-python\/#How_to_Get_Information_About_Zip_File\" >How to Get Information About Zip File<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-work-with-zip-files-in-python\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Why_Zip_Files_in_Python\"><\/span>Why Zip Files in Python<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>There are many use cases where you may need to work with zip files from within Python environment. For example, if you are developing a python-based website or application that allows users to upload one or more images\/documents, then you will need to support zip files to improve upload speed and save space.  After the zip file is uploaded to your website, you will need to extract it using a Python script. Therefore, you will need to use Python for zip files.<\/p>\n\n\n\n<p>Another advantage is that if you use Python scripts to work with zip files, then it becomes platform independent, since you do not need to rely on local apps and tools for this purpose.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Zipfile_Python_Module\"><\/span>Zipfile Python Module<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Python provides a powerful <a href=\"https:\/\/docs.python.org\/3\/library\/zipfile.html\">zipfile<\/a> module that allows you to easily perform various tasks on zip files in Python. You can use it on Python console or call it from inside Python script. It allows you to create, read as well as extract zip files in Python. You can import the zipfile module using the following command.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import zipfile<\/pre>\n\n\n\n<p>In most cases, we will be using ZipFile class from this module. So you can also directly import this as shown.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">from zipfile import ZipFile<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_Work_With_Zip_Files_in_Python\"><\/span>How to Work With Zip Files in Python<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Let us look at the different things you can do with zip files in Python.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_Create_Zip_File_in_Python\"><\/span>How to Create Zip File in Python<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>One of the most common requirements for people is to create a zip file from a set of files and folders. For this, you can use write() function as shown below.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">from zipfile import ZipFile<br><br>with ZipFile(\".\/data.zip\", \"w\") as zip:<br>    zip.write('file1.txt')<br>    zip.write('.\/projects')<\/pre>\n\n\n\n<p>In the above code, we have basically opened the target zip file in write mode. Then we have written individual file file1.txt and subfolder \/projects into the zip file. For each instance, we have called write() function to add to the zip file.<\/p>\n\n\n\n<p>If you want to add files in a folder to a zip, you may want to get a list of its files and subfolders and <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">from zipfile import ZipFile<br>file_paths=[]<br>directory='\/home\/ubuntu\/projects'<br><br>for root, directories, files in os.walk(directory):<br>        for filename in files:<br>            filepath = os.path.join(root, filename)<br>            file_paths.append(filepath)<br><br>with ZipFile(\".\/data.zip\", \"w\") as zip:<br>    for file in file_paths: <br>        zip.write(file) <br><\/pre>\n\n\n\n<p>In the above code, we first go through the names of files and subfolders of &#8216;\/home\/ubuntu\/projects&#8217; and store their full paths in a list. Then we loop through this list and add each of these files and folders, one by one, to the zip file.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_Read_Zip_File_Without_Opening\"><\/span>How to Read Zip File Without Opening<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Sometimes, you may want to just read the content of a single file without extracting it to the disk. Here is an example to read file test.txt in our zip file.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">from zipfile import ZipFile<br><br>with zipfile.ZipFile(\".\/data.zip\",\"r\") as zip:<br>    with zip.open(\"data\/assets\/test.txt\") as fp:<br>        print(fp.read().decode())<\/pre>\n\n\n\n<p>In the above code, we open the zip file in read mode. Then we call open() function on this zip file handler. Lastly, we call read().decode() function.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_Extract_Zip_File_in_Python\"><\/span>How to Extract Zip File in Python<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>One of the most common requirements is to simply extract a zip file to a given location. You can do this by opening the file in read mode &#8216;r&#8217; and calling extractall() function.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">from zipfile import ZipFile<br><br>with ZipFile(\".\/data.zip\", \"r\") as zip:<br>    zip.extractall() <\/pre>\n\n\n\n<p>The above code will extract all files and folders in zip file to current location.<\/p>\n\n\n\n<p>Sometimes, you may have a large zip file with many content and you may want to extract only a single file from it. In such cases, you can use the extract() function. Here is an example to extract only the file named test.txt.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">from zipfile import ZipFile<br><br>with ZipFile(\".\/data.zip\", \"r\") as zip:<br>    zip.extract('test.txt') <\/pre>\n\n\n\n<p>Please note, this use case is different from reading the content of single file, mentioned earlier. In this case, the file is extracted to the disk. In the earlier case, the file&#8217;s contents are read without extracting it.<\/p>\n\n\n\n<p>If your zip file is password protected then you will need to supply the password in extractall() function using its pwd argument.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">from zipfile import ZipFile<br><br>with ZipFile(\".\/data.zip\", \"r\") as zip:<br>    zip.extractall(pwd=bytes(<strong>&lt;password&gt;<\/strong>, 'utf-8')) <\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_List_Zip_File_Contents\"><\/span>How to List Zip File Contents<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Often you may need to view a zip file&#8217;s contents without extracting it. ZipFile module provides many functions to view a zip file&#8217;s contents without opening it. You can use listdir() function to view all the directories and files in a zip file in a tabular format. <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">from zipfile import ZipFile<br><br>with ZipFile(\"data.zip\") as zip:<br>    print(zip.printdir()) <\/pre>\n\n\n\n<p>You will see a table of output with file name, modified data and size.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">File Name                                    Modified                       Size<br>data\/                                        2025-04-24 19:00:16            0<br>data\/assets\/                                 2025-04-24 19:00:24            20<br>data\/assets\/index.txt                        2025-04-24 19:01:12            11<br>data\/configurations.txt                      2025-04-24 18:52:26            40<br>data\/sample.txt                              20255-04-24 18:52:16            0<\/pre>\n\n\n\n<p>Sometimes, you may want to get a list of directories and files in a zip file, as a list so that you can loop through them and do further processing. For this purpose, you can use namelist() function.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">from zipfile import ZipFile<br><br>with zipfile.ZipFile(\".\/data.zip\") as zip:<br>    print(zip.namelist()) # list of files and folders<\/pre>\n\n\n\n<p>You will see the following output list.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">['data\/', 'data\/assets\/', 'data\/assets\/index.txt', 'data\/configurations.txt', 'data\/sample.txt']<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_Add_Files_to_Zip_file\"><\/span>How to Add Files to Zip file<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Sometimes, you may need to add just one or few files to an existing zip file, without disturbing its other contents. For this, you can use write() function available in ZipFile class.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">from zipfile import ZipFile<br><br>with ZipFile(\".\/data.zip\", \"a\") as zip:<br>    zip.write(\"sample.txt\", arcname=\"project\/sample.txt\")<\/pre>\n\n\n\n<p>In the above code, we first open the zip file in append mode &#8216;a&#8217;. Please do not open the file in write mode, else the new file will completely overwrite the zip file&#8217;s existing contents instead of being appended to it.<\/p>\n\n\n\n<p>We call write() function to append the file to zip. We specify the file name\/path as first argument. By default, the file will be appended to the root location inside zip file. If you want to add it to another subfolder inside it, then use arcname argument and specify the file path inside zip file.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_Get_Information_About_Zip_File\"><\/span>How to Get Information About Zip File<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>If you need to meta information about a zip file&#8217;s contents, that is, its files and directories then you can use infolist() function. It will return a list of objects where each object contains file name, size, compression type, etc.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">from zipfile import ZipFile<br><br>with zipfile.ZipFile(\".\/data.zip\") as zip:<br>    print(zip.infolist()) # list of files and folders<\/pre>\n\n\n\n<p>Here is the output you will see.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[&lt;ZipInfo filename='data\/' external_attr=0x10&gt;, ...]<\/pre>\n\n\n\n<p>If you want to read the properties of the above displayed objects, then you can loop through them one by one to extract the information you need.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">with ZipFile(\".\/data.zip\") as zip: <br>    for file in zip.infolist(): <br>            print(file.filename) <br>            print('\\tModified:\\t' + str(datetime.datetime(*file.date_time))) <br>            print('\\tSystem:\\t\\t' + str(file.create_system) + '(0 = Windows, 3 = Unix)') <br>            print('\\tZIP version:\\t' + str(file.create_version)) <br>            print('\\tCompressed:\\t' + str(file.compress_size) + ' bytes') <br>            print('\\tUncompressed:\\t' + str(file.file_size) + ' bytes') <\/pre>\n\n\n\n<p>In the above code, we loop through the result of infolist() function. In each iteration, we read some of the properties available in the object, such as filename, date_time, create_version, compress_size, file_size.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In this article, we have learnt many common use cases to work with zip files in Python. We have learnt how to create zip file, how to extract one or more files from a zip file. We have also learnt how to read a file without opening zip file, how to add a single file to zip file. Lastly, we learnt how to get the list of a zip file&#8217;s contents without extracting it, and how to get the meta information about each of its files and folders. You can use any of these solutions as per your requirement. Please note, it is always advisable to use context managers along with file handlers so that they are automatically closed after processing completes.<\/p>\n\n\n\n<p>Also read:<\/p>\n\n\n\n<p><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-convert-pandas-dataframe-to-dictionary\/\">How to Convert Pandas Dataframe into Dictionary<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-convert-pandas-dataframe-to-list\/\">How to Convert Pandas Dataframe into List<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-compare-two-lists-in-python\/\">How to Compare Two Lists in Python<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes Python developers need to work with Zip files in Python. Here is how to extract, zip, read, write zip files in Python.<\/p>\n","protected":false},"author":1,"featured_media":7757,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[301],"tags":[409],"class_list":["post-7738","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-zip-files"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Work With ZIP Files in Python - Ubiq BI<\/title>\n<meta name=\"description\" content=\"Sometimes Python developers need to work with Zip files in Python. Here is how to extract, zip, read, write zip files in Python.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-work-with-zip-files-in-python\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Work With ZIP Files in Python - Ubiq BI\" \/>\n<meta property=\"og:description\" content=\"Sometimes Python developers need to work with Zip files in Python. Here is how to extract, zip, read, write zip files in Python.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ubiq.co\/tech-blog\/how-to-work-with-zip-files-in-python\/\" \/>\n<meta property=\"og:site_name\" content=\"Ubiq BI\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ubiqbi\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-15T06:40:03+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-01-20T10:21:51+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/04\/work-with-zip-file-python.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"300\" \/>\n\t<meta property=\"og:image:height\" content=\"200\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Sreeram Sreenivasan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@UbiqBI\" \/>\n<meta name=\"twitter:site\" content=\"@UbiqBI\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sreeram Sreenivasan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-work-with-zip-files-in-python\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-work-with-zip-files-in-python\/\"},\"author\":{\"name\":\"Sreeram Sreenivasan\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc\"},\"headline\":\"How to Work With ZIP Files in Python\",\"datePublished\":\"2025-04-15T06:40:03+00:00\",\"dateModified\":\"2026-01-20T10:21:51+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-work-with-zip-files-in-python\/\"},\"wordCount\":1251,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-work-with-zip-files-in-python\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/04\/work-with-zip-file-python.jpg?fit=300%2C200&ssl=1\",\"keywords\":[\"zip files\"],\"articleSection\":[\"Python\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/ubiq.co\/tech-blog\/how-to-work-with-zip-files-in-python\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-work-with-zip-files-in-python\/\",\"url\":\"https:\/\/ubiq.co\/tech-blog\/how-to-work-with-zip-files-in-python\/\",\"name\":\"How to Work With ZIP Files in Python - Ubiq BI\",\"isPartOf\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-work-with-zip-files-in-python\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-work-with-zip-files-in-python\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/04\/work-with-zip-file-python.jpg?fit=300%2C200&ssl=1\",\"datePublished\":\"2025-04-15T06:40:03+00:00\",\"dateModified\":\"2026-01-20T10:21:51+00:00\",\"author\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc\"},\"description\":\"Sometimes Python developers need to work with Zip files in Python. Here is how to extract, zip, read, write zip files in Python.\",\"breadcrumb\":{\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-work-with-zip-files-in-python\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/ubiq.co\/tech-blog\/how-to-work-with-zip-files-in-python\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-work-with-zip-files-in-python\/#primaryimage\",\"url\":\"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/04\/work-with-zip-file-python.jpg?fit=300%2C200&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/04\/work-with-zip-file-python.jpg?fit=300%2C200&ssl=1\",\"width\":300,\"height\":200,\"caption\":\"work with zip file in python\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/how-to-work-with-zip-files-in-python\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/ubiq.co\/tech-blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Work With ZIP Files in Python\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/#website\",\"url\":\"https:\/\/ubiq.co\/tech-blog\/\",\"name\":\"Ubiq BI\",\"description\":\"Build dashboards &amp; reports in minutes\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/ubiq.co\/tech-blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc\",\"name\":\"Sreeram Sreenivasan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"caption\":\"Sreeram Sreenivasan\"},\"description\":\"Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI &amp; software development.\",\"sameAs\":[\"https:\/\/www.linkedin.com\/in\/sreeram-sreenivasan\/\"],\"url\":\"https:\/\/ubiq.co\/tech-blog\/author\/wordpress\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Work With ZIP Files in Python - Ubiq BI","description":"Sometimes Python developers need to work with Zip files in Python. Here is how to extract, zip, read, write zip files in Python.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/ubiq.co\/tech-blog\/how-to-work-with-zip-files-in-python\/","og_locale":"en_US","og_type":"article","og_title":"How to Work With ZIP Files in Python - Ubiq BI","og_description":"Sometimes Python developers need to work with Zip files in Python. Here is how to extract, zip, read, write zip files in Python.","og_url":"https:\/\/ubiq.co\/tech-blog\/how-to-work-with-zip-files-in-python\/","og_site_name":"Ubiq BI","article_publisher":"https:\/\/www.facebook.com\/ubiqbi","article_published_time":"2025-04-15T06:40:03+00:00","article_modified_time":"2026-01-20T10:21:51+00:00","og_image":[{"width":300,"height":200,"url":"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/04\/work-with-zip-file-python.jpg","type":"image\/jpeg"}],"author":"Sreeram Sreenivasan","twitter_card":"summary_large_image","twitter_creator":"@UbiqBI","twitter_site":"@UbiqBI","twitter_misc":{"Written by":"Sreeram Sreenivasan","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-work-with-zip-files-in-python\/#article","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-work-with-zip-files-in-python\/"},"author":{"name":"Sreeram Sreenivasan","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"headline":"How to Work With ZIP Files in Python","datePublished":"2025-04-15T06:40:03+00:00","dateModified":"2026-01-20T10:21:51+00:00","mainEntityOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-work-with-zip-files-in-python\/"},"wordCount":1251,"commentCount":0,"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-work-with-zip-files-in-python\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/04\/work-with-zip-file-python.jpg?fit=300%2C200&ssl=1","keywords":["zip files"],"articleSection":["Python"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/ubiq.co\/tech-blog\/how-to-work-with-zip-files-in-python\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-work-with-zip-files-in-python\/","url":"https:\/\/ubiq.co\/tech-blog\/how-to-work-with-zip-files-in-python\/","name":"How to Work With ZIP Files in Python - Ubiq BI","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-work-with-zip-files-in-python\/#primaryimage"},"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-work-with-zip-files-in-python\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/04\/work-with-zip-file-python.jpg?fit=300%2C200&ssl=1","datePublished":"2025-04-15T06:40:03+00:00","dateModified":"2026-01-20T10:21:51+00:00","author":{"@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"description":"Sometimes Python developers need to work with Zip files in Python. Here is how to extract, zip, read, write zip files in Python.","breadcrumb":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-work-with-zip-files-in-python\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ubiq.co\/tech-blog\/how-to-work-with-zip-files-in-python\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-work-with-zip-files-in-python\/#primaryimage","url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/04\/work-with-zip-file-python.jpg?fit=300%2C200&ssl=1","contentUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/04\/work-with-zip-file-python.jpg?fit=300%2C200&ssl=1","width":300,"height":200,"caption":"work with zip file in python"},{"@type":"BreadcrumbList","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-work-with-zip-files-in-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/ubiq.co\/tech-blog\/"},{"@type":"ListItem","position":2,"name":"How to Work With ZIP Files in Python"}]},{"@type":"WebSite","@id":"https:\/\/ubiq.co\/tech-blog\/#website","url":"https:\/\/ubiq.co\/tech-blog\/","name":"Ubiq BI","description":"Build dashboards &amp; reports in minutes","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ubiq.co\/tech-blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc","name":"Sreeram Sreenivasan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","caption":"Sreeram Sreenivasan"},"description":"Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI &amp; software development.","sameAs":["https:\/\/www.linkedin.com\/in\/sreeram-sreenivasan\/"],"url":"https:\/\/ubiq.co\/tech-blog\/author\/wordpress\/"}]}},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/04\/work-with-zip-file-python.jpg?fit=300%2C200&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/pbGGTT-20O","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/7738","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/comments?post=7738"}],"version-history":[{"count":23,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/7738\/revisions"}],"predecessor-version":[{"id":10353,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/7738\/revisions\/10353"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media\/7757"}],"wp:attachment":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media?parent=7738"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/categories?post=7738"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/tags?post=7738"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}