0

I've been trying to load a .mat file on Google Colab, and it seems like my code failed to decompress the data into desired file.

Here is the loadData function,

def loadData(name):
    
    data_path = os.path.join(os.getcwd())
   
    if name == 'Flevoland':
        
        data = sio.loadmat(os.path.join(data_path, 'Flevoland_T3RF.mat'))['T3RF']
        labels = sio.loadmat(os.path.join(data_path, 'Flevoland_15cls.mat'))['label']
  
    if name == 'SanFrancisco':
        
        data = sio.loadmat(os.path.join(data_path, 'SanFrancisco_T3RF.mat'))['T3RF']
        labels = sio.loadmat(os.path.join(data_path, 'SanFrancisco_gt.mat'))['SanFrancisco_gt']

    
    return data, labels

Here are the global variables,

dataset = 'Flevoland'
test_ratio = 0.90
windowSize = 12

and here is the execution code:

X , Y = loadData(dataset)

This is the error message after running the code:

---------------------------------------------------------------------------
error                                     Traceback (most recent call last)
<ipython-input-41-7149ef2f6408> in <module>
----> 1 X , Y = loadData(dataset)

3 frames
/usr/local/lib/python3.8/dist-packages/scipy/io/matlab/mio5.py in read_var_array(self, header, process)
    290            `process`.
    291         '''
--> 292         return self._matrix_reader.array_from_header(header, process)
    293 
    294     def get_variables(self, variable_names=None):

mio5_utils.pyx in scipy.io.matlab.mio5_utils.VarReader5.array_from_header()

mio5_utils.pyx in scipy.io.matlab.mio5_utils.VarReader5.array_from_header()

mio5_utils.pyx in scipy.io.matlab.mio5_utils.VarReader5.read_real_complex()

mio5_utils.pyx in scipy.io.matlab.mio5_utils.VarReader5.read_numeric()

mio5_utils.pyx in scipy.io.matlab.mio5_utils.VarReader5.read_element()

streams.pyx in scipy.io.matlab.streams.ZlibInputStream.read_string()

streams.pyx in scipy.io.matlab.streams.ZlibInputStream.read_into()

streams.pyx in scipy.io.matlab.streams.ZlibInputStream._fill_buffer()

error: Error -3 while decompressing data: invalid code lengths set

How can I solve this issue?

I tried to execute the code, and can't load the data because of the error: Error -3 while decompressing data: invalid code lengths set.

Mark Adler
  • 101,978
  • 13
  • 118
  • 158
pdfMonkey
  • 13
  • 3
  • Have you tried loading the file it's failing on in MATLAB? That error indicates that the file is corrupted. – Mark Adler Jan 31 '23 at 01:52

0 Answers0