[Solved] How NOT to overwrite the .mat file when using scipy.io.savemat()?

I have been using Python’s scipy.io.savemat() to save my data in .mat format, efficient way to transfer data between the two: http://docs.scipy.org/doc/scipy-0.9.0/reference/tutorial/io.html.

Somehow it overwrite the file. How to set the function so I can append to the .mat file instead of overwriting just like MATLAB save()’s ‘-append’ option? Or is there any ways to work it out other than scipy.

io.savemat()?

Enquirer: B Wu

||
Solution #1:

There doesn’t appear to be a way to append with scipy.io.savemat().

You can scipy.io.loadmat(), append your new values to the dict that is returned, and then call scipy.io.savemat() again.

Here is the documentation for scipy.io.loadmat():

http://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.io.loadmat.html

Respondent: stu
The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Leave a Reply

Your email address will not be published.