import ts_set

import csv

# onehotencoser is python file which onehotencode each event
# and return them alnog with their remaining time
import onehotencoder

# mydatetime is python file which return diffrence between
# two timestamp in seconds.
import mydatetime

# encodedlist is a list which stores encoded list of each event
encodedlist = onehotencoder.encodedlist()

states, events, transitions = ts_set.TransitionSystem()

# read the data of log.csv and stores it in csvlog which
# is list of lists where each list contain all the feature
# of the event
csvlog = open("../../../Dataset/log.csv", "r").read().split("\n")
event_number = 0
for line in csvlog:
    line = line.split(",")
    csvlog[event_number] = line
    event_number += 1

noofrow = len(csvlog) - 1  #number of row in the dataset
noofcol = len(csvlog[0])  #number of coloumn in dataset

feature_data = []
import csv
import mydatetime

A = []
P = []
csvlog = open("../Dataset/log.csv", "r").read().split("\n")
j = 0
for i in csvlog:
    i = i.split(",")
    csvlog[j] = i
    j += 1
noofrow = len(csvlog) - 1
k = noofrow
noofcol = len(csvlog[0])
a4 = 0
states, events, transitions, avgremtime = ts_set.TransitionSystem()
for i in range(1, noofrow // 5):
    for j in range(i, noofrow + 1):
        if csvlog[i][0] != csvlog[j][0]:
            j = j - 1
            break
    if csvlog[j][3] != "Send for Credit Collection":
        continue
    curr_state = ['start']
    if csvlog[i][0] != csvlog[i - 1][0]:
        trace_start = i
    for ii in range(trace_start, i + 1):
        curr_state.append(csvlog[ii][3])
    curr_state = list(set(curr_state))
    for j in range(i, noofrow + 1):
        if (csvlog[j][0] != csvlog[i][0]):