-
Notifications
You must be signed in to change notification settings - Fork 0
/
convert.py
43 lines (29 loc) · 843 Bytes
/
convert.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 re
import sys
journal_path = sys.argv[1]
dir_path = sys.argv[2]
counter = 0
def write_jot(contents):
global counter
counter = counter + 1
with open("{}/{:014}.jot".format(dir_path, counter), 'w') as out:
out.write(contents)
with open(journal_path) as journal:
all_lines = journal.read().splitlines()
wip_jot = ''
reg = '\[(\d\d\d\d\-\d\d\-\d\dT\d\d:\d\d:\d\d-\d\d:\d\d)(.*?)\].*'
for line in all_lines:
found = re.search(reg, line)
if found:
# Write out wip_jot
print(wip_jot)
print("#############")
write_jot(wip_jot)
wip_jot = line
else:
wip_jot = wip_jot + '\n'
wip_jot = wip_jot + line
print(wip_jot)
write_jot(wip_jot)
print('************')
# write out wip_jot