-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest2.py
More file actions
38 lines (35 loc) · 765 Bytes
/
Copy pathtest2.py
File metadata and controls
38 lines (35 loc) · 765 Bytes
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
import pdb
f=open('temp.data','r')
beginning=[]
middle=[]
end=[]
i=0
for line in f:
line=line[:len(line)-1]
line=line.split(') (')
if len(line)==1:
line=line[:len(line)-1]
for index,phrase in enumerate(line):
if index==0:
beginning.append(phrase)
elif index==len(line)-1:
end.append(phrase)
else:
middle.append(phrase)
# print len(beginning[i]) + len(middle[i]) + len(end[i]) == len(line)
f.close()
b=open('beginning.data','w')
for p in beginning:
b.write(p+')')
b.write('\n')
b.close()
b=open('middle.data','w')
for p in middle:
b.write('('+p+')')
b.write('\n')
b.close()
b=open('end.data','w')
for p in end:
b.write('('+p)
b.write('\n')
b.close()