-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommons.py
44 lines (35 loc) · 937 Bytes
/
commons.py
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
44
import json
import csv
# Input
def load_json(file_name):
with open(file_name) as f:
output = json.load(f)
return output
# Output
def save_json(file_name, data):
with open(file_name,'w') as f:
json.dump(data, f)
# Input
def load_csv(file_name):
with open(file_name, "r") as f:
read_obj = csv.reader(f)
output = []
for row in read_obj:
output.append(row)
f.close()
return output
# Output
def save_csv(file_name, data_send):
with open(file_name, "w") as f:
if len(data_send) == 0:
f.close()
return
else:
for item in data_send:
csv.writer(f).writerow(item)
f.close()
return
## Make grid plotter with matplotlib
## Make easy clean image generator with no axis
## Add matplotlib numpy PyQT5 to requirements
## Maybe add the web generator for interactive plots