Compress an existing file using h5py

I am currently working on a project to compress HDF5 datasets and have recently started using h5py. I followed the basic tutorials and was able to open, create and compress the file during its creation. However, I was not successful when it comes to compressing an existing file (which is the purpose of my work).

I tried opening files with "r +" and then compressing the batch data sets, but the file sizes remained the same.

Any suggestions on which commands to use or what I'm doing wrong?

+5
source share
1 answer

Compression is very easy to use in h5py. Check out the Wiki HowTo and Compression tutorials. Basically, it will be something like:

ds = myfile.create_dataset('ds', shape, dtype, compression='lzf')

There are also some problems with the way you select block sizes to optimize file / access size, see the compression guide I'm associated with.

I don’t remember which compression, if any, is enabled by default.

+3
source

All Articles