[Numpy-discussion] Question about np.savez

Jorge Scandaliaris jorgesmbox-ml at yahoo.es
Tue Sep 1 22:11:09 EDT 2009


David Warde-Farley <dwf <at> cs.toronto.edu> writes:
> If you actually want to save multiple arrays, you can use  
> savez('fname', *[a,b,c]) and they will be accessible under the names  
> arr_0, arr_1, etc. and a list of these names is in the 'files'  
> attribute on the NpzFile object. To retrieve your list of arrays when  
> you load, you can just do
> 
> mynewlist = [data[arrname] for arrname in data.files]
> 

Thanks for the tip. I have realized, though, that I might need some more
flexibility than just the ability to save ndarrays. The data I am dealing with
is best kept in a hierarchical way (I could represent the structure with
ndarrays also, but I think it would be messy and difficult). I am having a look
at h5py to see if it fulfill my needs. I know there is pytables, too, but from
having a quick look it seems h5py is simpler. Am I right on this?. I also get a
nice side-effect, the data would be readable by the de-facto standard software
used by most people in my field.

Jorge






More information about the NumPy-Discussion mailing list