-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextFileScript.py
More file actions
105 lines (83 loc) · 3.32 KB
/
TextFileScript.py
File metadata and controls
105 lines (83 loc) · 3.32 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
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#sciprt to text BST vs LS from java code
import subprocess
import os
def executeAVL(DataFile):
path = "/home/alaric/Documents/CSC2/Ass2/DataFiles/"
NewFile = DataFile[:-4]
file = open(path + DataFile, "r")
filew = open("/home/alaric/Documents/CSC2/Ass2/DataFiles/FinalData/"+ NewFile + "_AVL_Data.txt", "w")
while True:
line = file.readline().strip()
if line == '':
file.close()
# either end of file or just a blank line.....
# we'll assume EOF, because we don't have a choice with the while loop!
break
else:
arr = line.split(' ', 1)
key = arr[0]
arr = (key.split('_', 2))
s = subprocess.check_output("""java AVLTApp """ + arr[0] + ' ' + arr[1] + ' ' + arr[2] + ' ' +DataFile, shell= True)
x = (s.decode("utf-8")) #places the output of the java LSArrayApp into a string called x
y = x.split('\n', 5) # split based on the lines output from the java file
x = (y[5])[:-1] + ',' +(y[3]) + '\n' # make x a String that has the Number of Search Comparisons[line 6], Number of Insert Comparisons
filew.write(x)
filew.close()
def executeBST(DataFile):
#store the output of the java prgram
#LengthOfFile = len(open(DataFile).readlines())
NewFile = DataFile[:-4]
path = "/home/alaric/Documents/CSC2/Ass2/DataFiles/"
file = open(path + DataFile, "r")
filew = open("/home/alaric/Documents/CSC2/Ass2/DataFiles/FinalData/" + NewFile + "testtest.txt", "w")
while True:
line = file.readline().strip()
if line == '':
file.close()
# either end of file or just a blank line.....
# we'll assume EOF, because we don't have a choice with the while loop!
break
else:
arr = line.split(' ', 1)
key = arr[0]
arr = (key.split('_', 2))
s = subprocess.check_output("""java LSBSTApp """ + arr[0] + ' ' + arr[1] + ' ' + arr[2] + ' ' +DataFile, shell= True)
x = (s.decode("utf-8"))
y = x.split('\n', 5)
x = y[4] +',' + y[2] +'\n'
filew.write(x)
filew.close()
def executeBTree(DataFile):
#store the output of the java prgram
#LengthOfFile = len(open(DataFile).readlines())
NewFile = DataFile[:-4]
path = "/home/alaric/Documents/CSC2/Ass2/DataFiles/"
file = open(path + DataFile, "r")
filew = open("/home/alaric/Documents/CSC2/Ass2/DataFiles/FinalData/" + NewFile + "_BTree_Data.txt", "w")
while True:
line = file.readline().strip()
if line =='':
file.close()
break
else:
arr = line.split(' ', 1)
key = arr[0]
arr = (key.split('_', 2))
s = subprocess.check_output("""java BTreeApp """ + arr[0] + ' ' + arr[1] + ' ' + arr[2] + ' ' +DataFile, shell= True)
x = (s.decode("utf-8"))
y = x.split('\n', 5)
x = y[4] +',' + y[2] +'\n'
filew.write(x)
filew.close()
"""
for i in range(2,11):
if __name__=="__main__":
executeAVL("SubSet" + str(i) + ".txt")
"""
for i in range(1):
if __name__=="__main__":
executeBST("SubSet1" + ".txt")
"""
if __name__=="__main__":
executeBST("SubSet" + str(i) + ".txt")
"""