On Wed, Jun 23, 2010 at 3:46 AM, Ruben Salvador <rsalvador...@gmail.com> wrote: > Hi there, > > I have a .npy file built by succesively adding results from different test > runs of an algorithm. Each time it's run, I save a numpy.array using > numpy.save as follows: > > fn = 'file.npy' > f = open(fn, 'a+b') > np.save(f, arr) > f.close()
How about using h5py? It's not part of numpy but it gives you a dictionary-like interface to your archive: >> import h5py >> io = h5py.File('/tmp/data.hdf5') >> arr1 = np.array([1, 2, 3]) >> arr2 = np.array([4, 5, 6]) >> arr3 = np.array([7, 8, 9]) >> io['arr1'] = arr1 >> io['arr2'] = arr2 >> io['arr3'] = arr3 >> io.keys() ['arr1', 'arr2', 'arr3'] >> io['arr1'][:] array([1, 2, 3]) You can also load part of an array (useful when the array is large): >> io['arr1'][-1] 3 _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion