-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathangledat.py
32 lines (31 loc) · 935 Bytes
/
angledat.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
# This file is from Angle Data
def read_dict(filename):
try:
filedat = open(filename, 'r')
file = filedat.readlines()
filedat.close()
except:
raise OSError("ERROR: Not able to open file!")
values = {}
#loop start
for line in file:
inp = line.strip()
# comments
if inp.startswith("$") or inp == "":
continue
else:
if not "^" in inp:
raise OSError("ERROR: Data assigned wrong!")
if inp.count("^") > 1:
raise OSError("ERROR: To many assign symbols!")
valuename, valuevalue = inp.split("^")
values[valuename.strip()] = valuevalue.strip()
return values
def getinhistory(filename, defin=0):
value = None
counter = 0
dict = read_dict(filename)
for name, value in dict:
if counter == defin:
value = value
counter += 1