There are a lot of use cases which involve storing CSV files compressed since the compression ratio is high, so we can save space. Sometimes we'd like to work directly on compressed files (so decompress on the fly) instead of storing the uncompressed version before working on the data.
Some of the following compression formats are widely used:
- Gzip:
filename.csv.gz
- XZ:
filename.csv.xz
- LZMA:
filename.csv.lzma
- BZip2:
filename.bz2
The Python standard library already provides modules to work with these formats (gzip, lzma and bz2), so we just need some helper functions to use these features easily when importing and exporting data.
There are a lot of use cases which involve storing CSV files compressed since the compression ratio is high, so we can save space. Sometimes we'd like to work directly on compressed files (so decompress on the fly) instead of storing the uncompressed version before working on the data.
Some of the following compression formats are widely used:
filename.csv.gzfilename.csv.xzfilename.csv.lzmafilename.bz2The Python standard library already provides modules to work with these formats (
gzip,lzmaandbz2), so we just need some helper functions to use these features easily when importing and exporting data.