Archived
32 lines
770 B
Python
32 lines
770 B
Python
#!/usr/bin/python
|
|
|
|
import json
|
|
from load_matrix import loadmat
|
|
from pymatreader import read_mat
|
|
import os
|
|
|
|
|
|
def main(f):
|
|
|
|
matFile = os.path.join(
|
|
"/home/nao/Documents/Backups/Participant results/Sam/", f)
|
|
mat = loadmat(matFile)
|
|
results = mat["results"]
|
|
jsonFile = os.path.join(
|
|
"/home/nao/Documents/Backups/Participant results/Sam/", os.path.splitext(f)[0] + ".json")
|
|
with open(jsonFile, 'w+') as fl:
|
|
fl.write(json.dumps(results, indent=4, sort_keys=True))
|
|
fl.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
import argparse
|
|
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument('f', help='.mat file to be created into json')
|
|
|
|
args = parser.parse_args()
|
|
|
|
main(args.f)
|
|
print '--- Operation Completed ---'
|