-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtab_to_xes.py
More file actions
31 lines (24 loc) · 872 Bytes
/
tab_to_xes.py
File metadata and controls
31 lines (24 loc) · 872 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
import sys
from opyenxes.factory.XFactory import XFactory
from opyenxes.id.XIDFactory import XIDFactory
from opyenxes.data_out.XesXmlSerializer import XesXmlSerializer
import random
def convert(x,y):
file1 = open(x, 'r')
log = XFactory.create_log()
count = 0
# Using for loop
print("Using for loop")
for t in file1:
trace = XFactory.create_trace()
for activity_label in t[:-1].split("\t"):
event = XFactory.create_event()
attribute = XFactory.create_attribute_literal("concept:name", activity_label)
event.get_attributes()["concept:name"] = attribute
trace.append(event)
log.append(trace)
with open(y, "w") as f:
XesXmlSerializer().serialize(log, f)
if __name__ == "__main__":
for x in ["all.tab_729.","all.tab_6552."]:
convert(x+"tab",x+"xes")