Discussion
Loading...

Post

Log in
  • About
  • Code of conduct
  • Privacy
  • Users
  • Instances
  • About Bonfire
El Duvelle
El Duvelle
@elduvelle@neuromatch.social  路  activity timestamp 2 weeks ago

Slightly technical coding question, #Matlab to #Python:
What's the simplest way to read a Matlab table in Python?
Or, if that's not possible, what should I convert my Matlab table to so I can read it in python? 馃檹
It's quite a big table with "nested" data i.e. some of the columns contain different-lengths arrays for each row and some contain matrices.

Links I've tried without success:
https://stackoverflow.com/questions/25853840/load-matlab-tables-in-python-using-scipy-io-loadmat (csv doesn't save all the data)
https://pythonguides.com/python-scipy-load-mat-file/ (about reading .mat files but does not seem to work with tables)

Links I haven't tried:
https://www.mathworks.com/help/matlab/matlab_external/use-matlab-tables-and-timetables-in-python.html (I believe this relies on having a working version of Matlab to use Matlab.engine to read the file, which kinds of defeats the purpose)

#Programming #NeuroMethods

Python Guides

How to Load MAT Files in Python SciPy

How to load MATLAB .mat files in Python using SciPy and h5py. This guide covers standard MAT files, HDF5 format, and converting to Pandas DataFrame with examples
Stack Overflow

load matlab tables in python using scipy.io.loadmat

Is it possible to load matlab tables in python using scipy.io.loadmat? What I'm doing: In Matlab: tab = table((1:500)') save('tab.mat', 'tab') In Python: import scipy.io mat = scipy.io.loadmat(...
  • Copy link
  • Flag this post
  • Block
manisha
manisha
@manisha@neuromatch.social  路  activity timestamp 2 weeks ago

@elduvelle maybe a pandas dataframe would work?

  • Copy link
  • Flag this comment
  • Block
El Duvelle
El Duvelle
@elduvelle@neuromatch.social  路  activity timestamp 2 weeks ago

@manisha yes that might work (see method 3 in this link: https://pythonguides.com/python-scipy-load-mat-file/) but I am having problems simply loading the table in Python.. I don't think pandas has a way to load directly from Matlab table file, at least I didn't find any..

Python Guides

How to Load MAT Files in Python SciPy

How to load MATLAB .mat files in Python using SciPy and h5py. This guide covers standard MAT files, HDF5 format, and converting to Pandas DataFrame with examples
  • Copy link
  • Flag this comment
  • Block
manisha
manisha
@manisha@neuromatch.social  路  activity timestamp 2 weeks ago

@elduvelle ah I see :(

  • Copy link
  • Flag this comment
  • Block

bonfire.cafe

A space for Bonfire maintainers and contributors to communicate

bonfire.cafe: About 路 Code of conduct 路 Privacy 路 Users 路 Instances
Bonfire social 路 1.0.2-alpha.34 no JS en
Automatic federation enabled
Log in
Instance logo
  • Explore
  • About
  • Members
  • Code of Conduct