-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExampleWriteData.py
More file actions
30 lines (26 loc) · 1.02 KB
/
Copy pathExampleWriteData.py
File metadata and controls
30 lines (26 loc) · 1.02 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
import time
file = time.strftime("%Y%m%d-%H%M%S")
print 'Code to save data to a file named:', file
def main():
while True:
while True:
try:
airSpeed = int(input('Entry air speed (km/h): '))
ampere = int(input('Entry Ampere (A): '))
resistence = int(input('Entry Resistance (Ohm): '))
break
except (NameError, ValueError, SyntaxError) as err:
print 'Oops! That was no valid number. Try again...', err
pass
if (airSpeed == 0 & ampere == 0 & resistence == 0):
break
try:
f = open(file,'a')
f.write(str(airSpeed)+'\t'+ str(ampere)+'\t'+ str(resistence)+'\t'+ str(ampere*resistence)+'\n')
f.close()
print 'Air Speed', airSpeed, 'Current', ampere, 'Resistance', resistence, 'Voltage', (ampere*resistence), ' Saved'
except OSError as err:
print("OS error: {0}".format(err))
print ('Close')
if __name__ == "__main__":
main()