I'm trying to read a mat file using python's scipy io library, specifically a struct that contains an array of datetimes but it's not getting the information from the array. How do I extract the information?(An example of a cell: 22-Jul-2017)
import scipy.io as sio
# create string value to mat file
matPath = 'data/2017_Pervious11_F5.mat'
# load the information in the file in a format that python can interpret
matfile = sio.loadmat(matPath)
# in order: for slab1 get date_time, rn, qh,qe,qg and sup
s1_dates = matfile['S1']['D']
Output:
s1_dates [ MatlabOpaque([ (b'', b'MCOS', b'datetime', array([[3707764736],[ 2], [ 1], [ 1], [ 12],[ 2]], dtype=uint32))], dtype=[('s0', 'O'), ('s1', 'O'), ('s2', 'O'), ('arr', 'O')])]
One solution that worked for me was to convert all matrix entries to 'char' format (in MATLAB), and load the new .mat file using the 'scipy.io.loadmat'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With