Python Forum
How to remove empty struct from matlab file in python?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to remove empty struct from matlab file in python?
#1
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:

1
2
3
4
5
6
7
8
9
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to remove unwanted images and tables from a Word file using Python? rownong 2 903 Feb-04-2025, 08:30 AM
Last Post: Pedroski55
  Media Pipe Python Interfacing with MATLAB cmcreecc 1 1,029 May-30-2024, 07:23 AM
Last Post: TrentErnser
  Python Struct Question, decimal 10, \n and \x0a. 3python 2 1,487 Aug-11-2023, 09:29 AM
Last Post: 3python
  Cursor write 3rd file empty paulo79 3 2,882 Mar-10-2022, 02:51 PM
Last Post: DeaD_EyE
  Remove empty keys in a python list python_student 7 5,759 Jan-12-2022, 10:23 PM
Last Post: python_student
  JS Buffer.from VS struct.pack DreamingInsanity 3 3,667 Apr-05-2021, 06:27 PM
Last Post: DreamingInsanity
  Remove single and double quotes from a csv file in 3 to 4 column shantanu97 0 8,745 Mar-31-2021, 10:52 AM
Last Post: shantanu97
  how to remove \n from file? shams 7 5,198 Feb-04-2021, 07:56 AM
Last Post: shams
Photo Matlab to Python Sateesh 0 2,174 Nov-04-2020, 09:11 AM
Last Post: Sateesh
  From Matlab to Python erbab 1 2,714 Oct-27-2020, 02:16 PM
Last Post: jefsummers

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020