Skip to content

Instantly share code, notes, and snippets.

@benkamphaus
Created January 17, 2017 22:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benkamphaus/153691aa9b2958fae888f74695d88c86 to your computer and use it in GitHub Desktop.
Save benkamphaus/153691aa9b2958fae888f74695d88c86 to your computer and use it in GitHub Desktop.
Use Python to dump a variable in a mat file into a numpy format delimited text file
# requires scipy and numpy:
# e.g., with:
# pip install scipy numpy
import sys
import scipy.io as sio
from numpy import savetxt
filein = sys.argv[1]
fileout = sys.argv[2]
arr_dict = sio.loadmat(filein)
try:
var = sys.argv[3]
arr = arr_dict[var]
savetxt(fileout, arr)
except:
print(arr_dict.keys())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment