Created
November 29, 2011 14:54
-
-
Save swarbhanu/1405068 to your computer and use it in GitHub Desktop.
Creating a dataset and writing an array into an hdf5 file 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 numpy as np | |
import h5py as hp | |
filename='h5py1.h5' | |
#open a file | |
f=hp.File(filename,driver='sec2',mode='w') | |
#create a dataset | |
mydset=f.create_dataset("mydset",(10,10),'=f8',maxshape=(None,None)) | |
#write an array into the dataset | |
mydset=np.array(np.arange(5*3)).reshape((5,3)) | |
#print the array in the dataset | |
print mydset[:,:] | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment