Last active
June 2, 2018 06:15
-
-
Save prerakmody/fed4240a46eb9d5e4f912c1fdddd5041 to your computer and use it in GitHub Desktop.
Hacks with the HDF5 format using h5py
This file contains 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 | |
import numpy as np | |
filename = 'filename.h5' | |
data = h5py.File(filename) | |
nodes = list(data.items()) | |
data_path= '/a/b' #mention the node you are interested in | |
#Convert to .csv | |
filename_save = 'filename.csv' | |
np.savetxt(filename_save, data[data_path], delimiter=',') |
This file contains 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 numpy as np | |
## Saves a .npy file | |
X = np.ones((5,5)) | |
y = np.ones((3,3)) | |
url_npz = 'data_npy/train_{0}'.format('%.5d' % (i)) | |
np.savez_compressed(url_npz, X=X, Y=Y) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment