1

I have a -v7 file myfilename which I created in matlab. It contains a nested structure, which contains a UTC timestamp

 mydata.sub1.time_utc(1)
ans = 
   31-Jan-2018 09:25:52
    class(s.sub1.time_utc)
ans =
datetime

I open the file via python, using scipy

matlabcontents=scipy.io.loadmat(fn_full)

then I can access all of my struct but not the time_utc but then I can not see inspecting the object

matlabcontents['mydata']['sub1']

I can not see the 'time_utc' in the fields.

I also have tried :

matlabcontents=scipy.io.loadmat(myfilename ,squeeze_me=True,struct_as_record=False)
matlabcontents['mydata'].__dict__['sub1'].__dict__['time_utc']

This way I can access 'time_utc', but I get the following which is indeed 'opaque' to me

MatlabOpaque([ ('', 'MCOS', 'datetime', array([3707764736,          2,          1,          1,          1,
                1], dtype=uint32))], 
      dtype=[('s0', 'O'), ('s1', 'O'), ('s2', 'O'), ('arr', 'O')])

How to access matlab datetimes from python?

Mukul Kant
  • 7,074
  • 5
  • 38
  • 53
00__00__00
  • 4,834
  • 9
  • 41
  • 89

0 Answers0