Troubleshoot Dumping large numpy arrays using hd5py

Dumping large numpy arrays using hd5py

 

 import numpy as np

import h5py
#some dummy data to dump
data_to_write = np.random.random(size=(100,20)) # or some such
#dump the data to a file
with h5py.File('name-of-file.h5', 'w') as hf:
    hf.create_dataset("name-of-dataset",  data=data_to_write)
#read back the data
with h5py.File('name-of-file.h5', 'r') as hf:
    data = hf['name-of-dataset'][:]

No comments:

Post a Comment