pythonscipymat-file

Scipy loadmat only load integers?


It seems that I can only load everything as uint8 type, just with the following two lines,

import scipy.io
X1=scipy.io.loadmat('one.mat')

all double precision numbers get transformed. What should I do?


Solution

  • What level matfile are you trying to read? According to the docs,

    v4 (Level 1.0), v6 and v7 to 7.2 matfiles are supported.

    You will need an HDF5 python library to read matlab 7.3 format mat files. Because scipy does not supply one, we do not implement the HDF5 / 7.3 interface here.

    For the supported levels, variables should be reloaded with the dtype with which they were saved; if you'd rather load them as matlab would, add mat_dtype=True at the end of the parameters with which you call loadmat.