Skip to content

Instantly share code, notes, and snippets.

@swarbhanu
Created November 29, 2011 14:54
Show Gist options
  • Save swarbhanu/1405068 to your computer and use it in GitHub Desktop.
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
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