-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathterminalgrabber.py
70 lines (52 loc) · 2.13 KB
/
terminalgrabber.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import tkinter as tk
from tkinter.filedialog import askopenfilename
import numpy as np
tk.Tk().withdraw() # Says that you won't be using many tkinter functions
def saveResults():
# Open the file inside the project path, appending it
try:
fileToLoad = open(askopenfilename(), 'r')
# Save the CODE variable to the User's C++ Project.
print(fileToLoad)
fileToSave = open(askopenfilename(), 'a')
fileToSave.write(fileToLoad.read())
print(fileToSave)
fileToSave.close()
print("Saved!")
except:
print("Not Saved. ):")
def readPerformance(performanceString):
"""buffer = np.array([]) # Code that I struggled to make but as it turns out I
# only needed one line of code. ):
useForDistance = False
lastCheckWasFalse = False
decimalContainerString = ""
for i in range(0, len(performanceString)):
if performanceString[i].isdigit() is True or performanceString[i] == ".":
decimalContainerString = decimalContainerString + str(performanceString[i])
lastCheckWasFalse = False
print(str(performanceString[i]))
else:
if not lastCheckWasFalse:
print("String: ", decimalContainerString)
finalNumberToAdd = np.int32(decimalContainerString)
buffer = np.append(buffer, [finalNumberToAdd, useForDistance])
decimalContainerString = ""
lastCheckWasFalse = True
useForDistance = not useForDistance
finalNumberToAdd = np.int32(decimalContainerString)
buffer = np.append(buffer, [finalNumberToAdd, useForDistance])
ogBufferSize = buffer.size
print(ogBufferSize)
for i in range(0, ogBufferSize - 1):
if i % 2:
buffer = np.delete(buffer, i)
print(buffer)"""
stringbuffer = np.array([])
returnBuffer = np.array([])
stringbuffer = np.append(stringbuffer, performanceString.split(","))
if (stringbuffer.size != 0):
for val in stringbuffer:
returnBuffer = np.append(returnBuffer, float(val))
print(returnBuffer)
return returnBuffer