简体   繁体   中英

How to extract and read a bzip2ed hdf5 file in Python?

everything is in the question.

I use pytables to treat hdf5 files. When I receive a hdf5.bz2 file I can treat it if I uncompress it first in my file manager.

I don't find a proper way to extract my hdf5 file from a hdf5.bz2 file with python, can someone give me a hint?

Is there a way to do it directly with the instruction

tables.open_file(hdf5.bz2) 

adding some parameters?

Thanks a lot

The best solution I've found so far is to use a shell instruction via subprocess:

try:
    subprocess.run(['bzip2', '-d',  hdf5.bz2])
except Exception as e:
    logger.exception(e)

It works fine, still looking for a more pythonic solution. Ciao

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM