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:

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
  Python Struct Question, decimal 10, \n and \x0a. 3python 2 674 Aug-11-2023, 09:29 AM
Last Post: 3python
  Cursor write 3rd file empty paulo79 3 1,902 Mar-10-2022, 02:51 PM
Last Post: DeaD_EyE
  Remove empty keys in a python list python_student 7 3,038 Jan-12-2022, 10:23 PM
Last Post: python_student
  JS Buffer.from VS struct.pack DreamingInsanity 3 2,466 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 6,986 Mar-31-2021, 10:52 AM
Last Post: shantanu97
  how to remove \n from file? shams 7 3,293 Feb-04-2021, 07:56 AM
Last Post: shams
Photo Matlab to Python Sateesh 0 1,682 Nov-04-2020, 09:11 AM
Last Post: Sateesh
  From Matlab to Python erbab 1 2,023 Oct-27-2020, 02:16 PM
Last Post: jefsummers
  Arrays in MATLAB and PYTHON cokhuatlanyeuthuongconhetmuc 2 2,209 Jul-24-2020, 10:47 AM
Last Post: cokhuatlanyeuthuongconhetmuc
  empty json file error mcmxl22 1 10,155 Jun-17-2020, 10:20 AM
Last Post: buran

Forum Jump:

User Panel Messages

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