How to append to .mat file using scipy.io.savemat?

后端 未结 3 1089
一个人的身影
一个人的身影 2020-12-10 15:49

so when I use the savemat command it tends to overwrite the file. Is there a possible way to append instead of overwriting? I know a work-around would be to put everything i

3条回答
  •  难免孤独
    2020-12-10 16:36

    It only works for one append!If you append twice, Matlab gives an error "File might be currupt".

    scipy.io.savemat('temp.mat',{'data':np.ones(10)})  # write
    with open('temp.mat','ab') as f:
        scipy.io.savemat(f, {'newdata1':np.arange(5)})   # append
    with open('temp.mat','ab') as f:
       scipy.io.savemat(f, {'newdata2':np.arange(5)})   # append
    

提交回复
热议问题