How to read contents of zip file in Python

Reading the contents of files inside a zip file is easy with Python. We can use the zipfile module to achieve this. Open the zip file using the ZipFile constructor. Get the list of files inside it using infolist() and open each of those files using open(). After that you can read from it just like a normal file.

Tried with: Python 2.7.3

Advertisements

One thought on “How to read contents of zip file in Python

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.