-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjsonToMATLAB.py
More file actions
executable file
·43 lines (33 loc) · 1.15 KB
/
jsonToMATLAB.py
File metadata and controls
executable file
·43 lines (33 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python
import numpy as np
import json
import scipy.io as sio
import sys
"""
This is a routine to convert my beautiful JSON files into MATLAB terribleness.
I'm an enabler. I said it.
Max, January 2016
"""
save_path = '/Users/elephant/Dropbox/Elephant Shared Folder/Data/MATLAB Data/'
if __name__ == '__main__':
if len(sys.argv) == 1:
print("\nUsage:\n python jsonToMATLAB path_to_your_file.json")
exit()
path = sys.argv[1]
file_name = path.split('/')[-1][:-5]
#try:
f = open(path)
# This is a list of dictionaries
data = json.load(f)
for n, d in enumerate(data):
print len(d)
dict_to_save = d['keithley']
#dict_to_save['roll'] = d['roll']
#dict_to_save['pitch'] = d['pitch']
#dict_to_save['countsA'] = d['countsA']
#dict_to_save['countsB'] = d['countsB']
#dict_to_save['gunVoltage'] = d['gunVoltage']
#dict_to_save['pressure'] = d['pressure']
sio.savemat(save_path+file_name+str(n), dict_to_save)
#except:
# print("Data file not loaded, did you use the wrong path?")