Loading video player…

Manipulating ZIP Files With Python (Overview)

Python’s zipfile is a standard-library module intended to manipulate ZIP files. This file format is a widely adopted industry standard when it comes to archiving and compressing digital data. You can use it to package together several related files. It also allows you to reduce the size of your files and save disk space. Most importantly, it facilitates data exchange over computer networks.

Knowing how to create, read, write, populate, extract, and list ZIP files using the zipfile module is a useful skill to have as a Python developer or a DevOps engineer.

In this video course, you’ll learn how to:

  • Read, write, and extract files from ZIP files with Python’s zipfile
  • Read metadata about the content of ZIP files using zipfile
  • Use zipfile to manipulate member files in existing ZIP files
  • Create new ZIP files to archive and compress files

If you commonly deal with ZIP files, then this knowledge can help to streamline your workflow to process your files confidently.

To get the most out of this video course, you should know the basics of working with files, using the with statement, handling file system paths with pathlib, and working with classes and object-oriented programming.

If you’d like to learn more about the REPL used in this course, check out Discover bpython: A Python REPL With IDE-Like Features. Note that all the code in this course will also run in the Python standard REPL.

Download

Sample Code (ZIP)

23.4 KB
Download

Course Slides (PDF)

12.6 MB

00:00 Manipulating ZIP Files With Python. Python’s zipfile is a standard-library module intended to manipulate ZIP files. This file format is a widely adopted industry standard when it comes to archiving and compressing digital data.

00:16 You can use it to package together several related files, and it also allows you to reduce the size of files and save disk space. Most importantly, it facilitates data exchange over computer networks.

00:28 Knowing how to create, read, write, populate, extract, and list ZIP files using the zipfile module is a useful skill to have as a Python developer or DevOps engineer. In this course, you’ll learn how to read, write, and extract files from ZIP files, read metadata about the contents of ZIP files, use zipfile to manipulate member files in existing ZIP files, and create new ZIP files to archive and compress files.

00:57 If you commonly deal with ZIP files, then this knowledge can help streamline your workflow to process your files confidently. To get the most out of this course, you should know the basics of working with files, using the with statement, handling file system paths with pathlib, and working with classes and object-oriented programming. As ever, Real Python has you covered with this video course on working with files,

01:22 this one covering the with statement,

01:26 this one on pathlib,

01:30 and this one on object-oriented programming.

01:35 The files and archives that you’ll be working with are available in the course materials, so make sure you download them to allow you to get up and running straight away.

01:44 Any code that you see running in the REPL will be using the bpython interpreter. This is a replacement Python interpreter that offers a number of enhancements, including code highlighting and suggestions, but any code you see running on-screen will work in the standard Python REPL, which is typically accessed by typing python or python3 at your terminal or command-line prompt. So now you know what’s going to be covered, let’s get started.

Become a Member to join the conversation.