-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconverter.py
More file actions
39 lines (26 loc) · 1.04 KB
/
converter.py
File metadata and controls
39 lines (26 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
#!/usr/bin/env python
"""converter.py: Das Programm strukturiert NetTalk Logdateien neu, sodass diese nach Channels/Querys geordnet sind anstatt nach Zeit."""
__author__ = 'SIRprise'
import sys
import os.path
if len(sys.argv) > 1:
logfile=(str(sys.argv[1]))
if os.path.isfile(logfile):
with open(logfile, 'r', encoding='utf-8', errors='replace') as ins:
content = []
for line in ins:
templine=(line.strip()[1:])
templine=templine.split(':', 1)
content.append(templine)
ins.close()
content=sorted(content,key=lambda x: x[0])
outfile = open('konvertiert'+logfile+'.txt', 'w', encoding='utf-8', errors='replace')
for item in content:
templine=("\t".join(str(e) for e in item))
templine=templine.lstrip(' \t\r\n\0')
outfile.write("%s\n" % templine)
outfile.close()
else:
print("Logdatei nicht gefunden.")
else:
print("Bitte Dateiname der Quell-Logdatei als Parameter angeben.")