[SciPy-user] storing numpy arrays

Michael Hearne mhearne at usgs.gov
Thu Mar 12 18:50:08 EDT 2009


Conor - Thank you for your suggestion.  I am in fact already using 
pytables in another part of my application.  However, using PyTables for 
this portion is not a desirable option.

Perhaps I should rephrase the question:
What is the the most efficient way to serialize a numpy array into a 
structure that _could_ be written to a disk, or stuffed into a database, 
etc?

Thanks,

Mike Hearne

Michael Hearne wrote:
> I have a MySQL database, in which I would like to store a numpy array 
> as a BLOB.  I'm trying to find out the easiest/most efficient way to 
> store/extract this data.
>
> I looked at scipy.io.write_array, which looked somewhat promising, 
> until I saw the notice that this method is deprecated in favor of 
> numpy.savetxt.
>
> I could potentially use scipy.io.savemat/loadmat, but that would 
> require writing to a binary (.mat file), then reading it back in again 
> just to stuff it into the database.
>
> I could also use pickle, but I found a bug report somewhere that 
> pickle may do strange things to the array in the process or reading or 
> writing.
>
> Does anyone have any suggestions?
>
> Thanks,
>
> Mike
>
>




More information about the SciPy-User mailing list