-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileControl.py
More file actions
60 lines (44 loc) · 1.04 KB
/
FileControl.py
File metadata and controls
60 lines (44 loc) · 1.04 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
import re
def write1ToFile(w, file):
x = open(str(file), 'a')
x.write(str(w))
x.write("\n")
x.close()
def write2ToFile( w , y , file):
# Writes to inputs to a file separated by a comma
x = open(str(file), 'a')
x.write(str(w))
x.write(",")
x.write(str(y))
x.write("\n")
x.close()
def resetFile(file):
x = open(str(file), 'w')
x.write("")
x.close()
def combine2File(f1,f2):
try:
file1 = open(str(f1), 'r')
file2 = open(str(f2), 'r')
except:
print("Invalid File")
return
comb = []
for (i,j) in zip(file2,file1):
temp = []
i = i.replace("\n", "")
i = i.replace("[", "")
i = i.replace("]", "")
j = j.replace("\n","")
j+= ","
j += i
j = j.split(",")
for i in j:
temp.append(float(i))
comb.append(temp)
return comb
def main():
resetFile("Stock_Data.txt")
write2ToFile(2 , 110, "Stock_Data.txt")
if __name__ == "__main__":
main()