This repository has been archived on 2024-07-04. You can view files and clone it, but cannot push or open issues or pull requests.
laydi/bin/mat2ftsv
einarr 7e6bac20e1 FIXING STUFF!
Rename should be complete or almost so.
2008-12-05 22:07:56 +00:00

38 lines
943 B
Python
Executable File

#!/usr/bin/python
import sys
from getopt import getopt
def show_help():
print "mat2ftsv - Matlab matrix to laydi dataset converter."
print
print "Usage: mat2ftsv <mat-file> [<matfile> ...]"
print
print "Description: For each mat file given as input, a ftsv file"
print " will be created with the same name, but suffixed with.ftsv"
print " in addition to .mat or any other suffix already on the"
print " file name."
options, params = getopt(sys.argv[1:], 'h', ['help'])
for opt, val in options:
if opt in ['-h', '--help']:
show_help()
sys.exit(0)
if len(params) == 0:
show_help()
sys.exit(0)
from scipy import io
from numpy import ndarray
from laydi import dataset
fn_in = params[0]
data = io.loadmat(fn_in)
for key, value in data.items():
if isinstance(value, ndarray):
ds = dataset.Dataset(value, name=key)
dataset.write_ftsv(fn_in + '.ftsv', ds)