Python Forum

Full Version: How to remove empty struct from matlab file in python?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am new to working with matlab files and I have a problem with some matlab files that has empty structs in between structs that have values. an example of how the file looks like in matlab is shown.[Image: W3RD238]

in python my code is as below:

from scipy.io import loadmat

file = 'filepath'
mat_dict = {}
mat = hdf5storage.loadmat(file,matlab_compatible=True)
mat_dict.update(mat)
a = mat_dict['bt']
b = a.shape
print(b)
so for this file the shape return a size of (1,338) which shows 1X1 structs followed by empty structs and then 1X1 structs again towards the end.

I have no idea how to remove these empty structs and combine the ones which has values and hope to get some help here.
Thank you.