Skip to content

Instantly share code, notes, and snippets.

@srdg
Created March 23, 2018 10:18
Show Gist options
  • Save srdg/69d436f90be7d042d4abade086065050 to your computer and use it in GitHub Desktop.
Save srdg/69d436f90be7d042d4abade086065050 to your computer and use it in GitHub Desktop.
Convert .mat files to .csv files instantly
import numpy as np
import scipy.io
data = scipy.io.loadmat("filename.mat") # Enter your filename here
for i in data:
if '__' not in i and 'readme' not in i:
fp = open(i+".csv","w+") # numpy.savetext does not create files automatically
np.savetxt((i+".csv"),data[i],delimiter=',')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment