-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclean.py
More file actions
28 lines (25 loc) · 813 Bytes
/
clean.py
File metadata and controls
28 lines (25 loc) · 813 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
rawFile, newFile = 'raw.txt', 'data.txt'
def clean():
with open (rawFile, 'r') as raw, open (newFile, 'w') as new:
line = raw.readline().strip().split()[1:]
N = len(line)
while N > 0:
if N == 7:
string = ''
j = 0
for i in range(len(line)):
if j < 6:
string += line[i] + '\t'
j += 1
else:
string += line[i]
string += '\n'
new.write(string)
line = raw.readline().strip().split()[1:]
N = len(line)
else:
line = raw.readline().strip().split()[1:]
N = len(line)
continue
return 0
clean()