[SciPy-user] Save a list of arrays

Nuttall, Brandon C bnuttall at uky.edu
Wed Apr 22 09:35:58 EDT 2009


I thought that is what pickling does, see http://docs.python.org/library/pickle.html

Brandon Nuttall
bnuttall at uky.edu (KGS)
________________________________________
From: scipy-user-bounces at scipy.org [scipy-user-bounces at scipy.org] On Behalf Of Mathieu Dubois [mathieu.dubois at limsi.fr]
Sent: Wednesday, April 22, 2009 9:09 AM
To: SciPy Users List
Subject: [SciPy-user] Save a list of arrays

[I have posted this message this morning but apparently it is stuck
somewhere - sorry for multi-posting]

Hello,

I would like to save a list of arrays (each one has a different shape)
to a file.
For instance:
 >>> array1 = numpy.ones(2);
 >>> array2 = numpy.ones(5);
 >>> array3 = numpy.ones(1000);
 >>> list = [array1, array2, array3]

As my arrays are huge (each one contains several thousands values) I
would like a compressed file.
numpy.savez would be perfect (because it produces an archive of binary
files) but unfortunately numpy.savez(list) doesn't work because savez
needs each array individually.

So what's the best way to do that?

Maybe I could create an archive file in Python (using ZipFile) save each
array in a npy file and then write each file in the archive. But then,
will numpy.load be able to open the file?

Any help appreciated.
Kind regards,
Mathieu
_______________________________________________
SciPy-user mailing list
SciPy-user at scipy.org
http://mail.scipy.org/mailman/listinfo/scipy-user


More information about the SciPy-User mailing list