Python Forum
How to remove empty struct from matlab file in python? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: How to remove empty struct from matlab file in python? (/thread-19367.html)



How to remove empty struct from matlab file in python? - python_newbie09 - Jun-25-2019

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.