How to read a text file compressed using bzip2 in Python

One of the reasons that Python is awesome is that there is a package for almost anything you can imagine. For example, if you are handling text files of large sizes, then it is good idea to store them in a compressed format, like bzip2 for example.

It is easy to read in the lines of such a text file compressed using bzip2 in Python using the bz2 package:

Tried with: Python 2.7.3 and Ubuntu 12.04 LTS

Advertisements

2 thoughts on “How to read a text file compressed using bzip2 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.