Last active
July 14, 2020 09:07
-
-
Save BexTuychiev/c54bc613c736073b4aba04a89dd0e263 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Importing matlab files | |
import scipy.io | |
import pandas as pd | |
filename = "ja_data2.mat" | |
matlab = scipy.io.loadmat(filename) | |
print(type(matlab)) # prints out 'class <dict>' | |
# Saving DataFrames as MATLAB files | |
# Read any csv file | |
df = pd.read_csv('sample.csv') | |
# Rename DataFrame columns to suit them into MATLAB's file structures | |
df.rename(columns=lambda x: 'col_' + x.replace(' ', '_'), inplace=True) | |
scipy.io.savemat('new_matlab_name.mat', {'struct': df.to_dict('list')}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment