-
Notifications
You must be signed in to change notification settings - Fork 2
/
dataProc.py
78 lines (74 loc) · 1.41 KB
/
dataProc.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
70
71
72
73
74
75
76
77
78
import os
def getInfo():
path1=os.getcwd()
path1=path1+"/Keys_IV/Log.txt"
path2=os.getcwd()
path2=path2+"/Parts/"
mainFile=open(path1,'w')
lisDir=os.listdir(os.path.join(os.getcwd()+"/Parts"))
for i in lisDir:
f=open(path2+i,'r')
content=f.read()
mainFile.write(str(len(content)))
mainFile.write('::::')
f.close()
mainFile.close()
def Segment():
f=open('Secured.txt','r')
con=f.read()
f.close()
count=0
for char in con:
count+=1
k=0
limit=int(count/5)
for i in range(0,5):
name=str(i)+".txt"
path=os.path.join(os.getcwd()+"/Parts",name)
f=open(path,'w')
ctr=0
for j in range(k,count):
k+=1
f.write(con[j])
ctr+=1
if(ctr==limit and i!=4):
f.close()
break
f.close()
def trim():
path1=os.getcwd()
path1=path1+"/Keys_IV/Log.txt"
mainFile=open(path1,'r')
content=mainFile.read()
mainFile.close()
content=content.split('::::')
path2=os.getcwd()
path2=path2+"/Parts"
lisDir=os.listdir(path2)
tData=""
c=0
i=0
for j in lisDir:
path3=path2+"/"+j
f=open(path3,'r')
data=f.read()
f.close()
n=int(content[i])
tData=data[:n]
i+=1
open(path3,'w').close()
f=open(path3,'w')
f.write(tData)
f.close()
tData=""
def Merge():
mainFile=open("Output.txt","w")
for i in range(0,5):
name=os.path.join(os.getcwd()+"/Parts",str(i)+".txt")
f=open(name,"r")
cont=f.read()
print(cont)
mainFile.write(cont)
f.close()
os.remove(name)
mainFile.close()