At work, I was thinking up a Python script to stream through a bunch of compressed text files. I was starting to devise the logic to run through a list of filenames and present it as one input stream, when I thought “maybe There’s One Obvious Way To Do It already”.
A little Googling and voila! Python’s
fileinput module. Does exactly what I need it to do, right down to being able to detect and decompress
gzip compressed files. Even better Doug Hellmann has done a Python Module of the Week (PyMOTW) entry for
fileinput, meaning there’s clear usage examples on top of the excellent documentation.
I had a script to cleanly zip through a 100+ Mb of compressed data in under a hour. Python, it’s a beautiful thing.