-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathZLine.py
42 lines (33 loc) · 1.14 KB
/
ZLine.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
import fileinput
import sys
import time
import CRLF
def remove_at(i, s):
return s[:i] + s[i + 1:]
def inline(s):
max_length = 10
count_fix = 0
for line in fileinput.input(s, inplace=True):
if len(line) > max_length:
num_line = fileinput.filelineno()
sys.stderr.write("Line: %s Len: %s \n" % (num_line, len(line)))
line2 = remove_at(8, line)
print('{}'.format(line2), end='')
count_fix = count_fix + 1
else:
print('{}'.format(line), end='')
sys.stderr.write("Record Fix: %s \n" % count_fix)
def main(argv):
sys.stderr.write("File: %s \n" % argv)
sys.stderr.write("Fixing records.\n")
start_time = time.time()
inline(argv)
print("Fix time: %s sec " % (time.time() - start_time))
sys.stderr.write("Convert file to Unix.\n" )
fileOutput=argv + '_out'
sys.stderr.write("Output file: %s \n" % fileOutput)
start_time = time.time()
CRLF.dosToUnix(argv,fileOutput)
print("Convert time %s sec " % (time.time() - start_time))
if __name__ == "__main__":
main(sys.argv[1])