Scipy.io typeerror: buffer too small for the requested array

I have a problem in python. I use scipy, where I use scipy.io to download the .mat file. The .mat file was created using MATLAB.

listOfFiles = os.listdir(loadpathTrain)
      for f in listOfFiles:

         fullPath = loadpathTrain + '/' + f
         mat_contents = sio.loadmat(fullPath)
         print fullPath

Here's the error:

    Traceback (most recent call last):
  File "tryRankNet.py", line 1112, in <module>
    demo()
  File "tryRankNet.py", line 645, in demo
    mat_contents = sio.loadmat(fullPath)
  File "/usr/lib/python2.6/dist-packages/scipy/io/matlab/mio.py", line 111, in loadmat
    matfile_dict = MR.get_variables()
  File "/usr/lib/python2.6/dist-packages/scipy/io/matlab/miobase.py", line 356, in get_variables
    getter = self.matrix_getter_factory()
  File "/usr/lib/python2.6/dist-packages/scipy/io/matlab/mio5.py", line 602, in matrix_getter_factory
    return self._array_reader.matrix_getter_factory()
  File "/usr/lib/python2.6/dist-packages/scipy/io/matlab/mio5.py", line 274, in matrix_getter_factory
    tag = self.read_dtype(self.dtypes['tag_full'])
  File "/usr/lib/python2.6/dist-packages/scipy/io/matlab/miobase.py", line 171, in read_dtype
    order='F')
TypeError: buffer is too small for requested array

Everything is in a loop, and I checked the file size, where it gives an error, loading it interactively in IDLE.

Size (9.521), which is not huge at all. I tried to find if I should clear the buffer after each iteration of the loop, but I could not find anything.

Any help would be appreciated.

Thank.

+3
source share

Source: https://habr.com/ru/post/1747113/


All Articles