scipy.io 类型错误:缓冲区对于请求的数组来说太小

K_U*_*K_U 5 python file-io scipy

我在python中有问题。我正在使用 scipy,我使用 scipy.io 加载 .mat 文件。.mat 文件是使用 MATLAB 创建的。

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

         fullPath = loadpathTrain + '/' + f
         mat_contents = sio.loadmat(fullPath)
         print fullPath
Run Code Online (Sandbox Code Playgroud)

这是错误:

    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
Run Code Online (Sandbox Code Playgroud)

整个事情都在一个循环中,我通过在 IDLE 中以交互方式加载它来检查文件的大小,它给出了错误。

大小是 (9,521),一点也不大。我试图找出在每次循环迭代后是否应该清除缓冲区,但我找不到任何东西。

任何帮助,将不胜感激。

谢谢。