"""
Name: log_files.py
Author: <NAME>
Description: Different entities of the simulation 
"""

import logging
from datetime import datetime
import os
import shutil 

def read_entities_log(path=""):
    data = {}
    with open(path,'r') as file:
        titles = file.readline().replace(" ","").strip().split(";")[1:]
        lines = file.readlines()
        lines = [l.replace(" ","").strip().split(";") for l in lines]
        for l in lines:
            entity = l[0]

            ## Is there a dict yet? 
            # YES: Append the new values to the lists
            try: 
                data[entity]
                for t in range(len(titles)): 
                    key = titles[t]
                    try:
                        if l[t+1] != "":
                            data[entity][key].append(l[t+1])
                    except:
                        pass

            # NO: Create a dict and lists
            except: 
                data[entity] = {}
                for t in range(len(titles)):
                    key = titles[t]
                    try:
                        if l[t+1] != "":
                            data[entity][key] = [l[t+1]]
                    except:
                        pass
                        
            for t in range(len(titles)): 
                key = titles[t]
    return data
"""
Name: log_files.py
Author: <NAME>
Description: Different entities of the simulation 
"""

import logging
from datetime import datetime
import os
import shutil 

def read_entities_log(path=""):
    data = {}
    with open(path,'r') as file:
        titles = file.readline().replace(" ","").strip().split(";")[1:]
        lines = file.readlines()
        lines = [l.replace(" ","").strip().split(";") for l in lines]
        for l in lines:
            entity = l[0]

            ## Is there a dict yet? 
            # YES: Append the new values to the lists
            try: 
                data[entity]
                for t in range(len(titles)): 
                    key = titles[t]
                    try:
                        if l[t+1] != "":
                            data[entity][key].append(l[t+1])
                    except:
                        pass

            # NO: Create a dict and lists
            except: 
                data[entity] = {}
                for t in range(len(titles)):
                    key = titles[t]
                    try:
                        if l[t+1] != "":
                            data[entity][key] = [l[t+1]]
                    except:
                        pass
                        
            for t in range(len(titles)): 
                key = titles[t]
    return data
Name: log_files.py Author: <NAME> Description: Different entities of the simulation ## Is there a dict yet? # YES: Append the new values to the lists # NO: Create a dict and lists