Skip to content

Instantly share code, notes, and snippets.

@sergeyprokudin
Created March 7, 2019 13:05
Show Gist options
  • Save sergeyprokudin/d77a4f19737cda9864f5cc43558d454a to your computer and use it in GitHub Desktop.
Save sergeyprokudin/d77a4f19737cda9864f5cc43558d454a to your computer and use it in GitHub Desktop.
Small function to dave dictionary of numpy arrays to H5 file
import h5py
import os
def save_h5(savepath, arr_dict):
if os.path.exists(savepath):
os.remove(savepath)
h5ds = h5py.File(savepath)
for arr_name in arr_dict.keys():
h5ds.create_dataset(arr_name, data=arr_dict[arr_name], compression='gzip', compression_opts=4)
h5ds.close()
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment