[SciPy-User] saving a sparse matrix to file

Nathaniel Smith njs at pobox.com
Mon Jun 25 16:34:39 EDT 2012


On Mon, Jun 25, 2012 at 7:34 PM, Pengkui Luo <pengkui.luo at gmail.com> wrote:
> Is there a unified API to save a sparse matrix of any type (dok, lil, csc,
> ...) to file, as simple as pickle dump/load?

If you want a pickle, have you tried using Python's generic pickle
dump/load interface?

import cPickle
cPickle.dump(myobj, open("myfile.pickle", "w"))
myobj2 = cPickle.load(open("myfile.pickle"))

http://docs.python.org/library/pickle.html

-n



More information about the SciPy-User mailing list