scipy.io typeerror:缓冲区对于请求的数组来说太小了

时间:2010-05-26 03:18:03

标签: 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

这是错误:

    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

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

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

任何帮助都将不胜感激。

感谢。

0 个答案:

没有答案