Created
June 7, 2018 12:12
-
-
Save nhannguyen95/5c9367f947f0e8367e12c73f2e3528d3 to your computer and use it in GitHub Desktop.
HDF5 read & write
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import h5py | |
f = h5py.File('path/to/file', 'r') | |
# List all groups | |
print('Keys: %s' % f.keys()) | |
# Get data | |
key = 'random_data' | |
random_data = np.asarray(f[key]) | |
f.close() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import h5py | |
# Create random data | |
random_data = np.random.rand(2,2) | |
# Save data to HDF5 | |
f = h5py.File('path/to/file', 'w') | |
f.create_dataset('random_data', data=random_data) | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment