EVE Chatlog Parser

I’ve created a small python library that can parse EVE chatlogs for the sake of analyzing, formatting, or simply searching through them. You can find it HERE.

This is an excerpt from the README, showing the basic usage of the library:

Print general information about all chatlogs

import sys
from pathlib import Path
from chatlogs import *

paths = [Path(file) for file in sys.argv[1:]]

for session in parse_chatlog_multi(paths):
    print(repr(session))

Get all lines of a character

import sys
from pathlib import Path
from chatlogs import *

CHARACTER = "Arwen Estalia"
CHARACTER_LINES: list[Line] = []

paths = [Path(file) for file in sys.argv[1:]]

for session in parse_chatlog_multi(paths):
    for line in session.lines:
        if line.character == CHARACTER:
            CHARACTER_LINES.append(line)

Get all real jumps across all of your characters

import sys
from pathlib import Path
from chatlogs import *

JUMPS: dict[str, int] = {}

paths = [Path(file) for file in sys.argv[1:]]

for session in parse_chatlog_multi(paths):
    if session.jumps is None or len(session.jumps) <= 1:
        continue
    for jump in session.jumps[1:]:  # cut off the initial 'jump'
        if jump.system not in JUMPS:
            JUMPS[jump.system] = 0
        JUMPS[jump.system] += 1

Advanced filtering and error handling

import sys
from typing import Iterator
from pathlib import Path
from chatlogs import *

paths = [Path(file) for file in sys.argv[1:]]

def filter(s: Session) -> bool:
    return {"Arwen Estalia", "Another Character"} < s.participants \
           and s.start.year == 2024 \
           and s.channel not in ("Local", "Fleet")

def wrapper(iter: Iterator[Session]) -> Iterator[Session]:
    while True:
        try:
            n = next(iter)
            if filter(n):
                yield n
        except StopIteration:
            break
        except ChatlogParseError as e:
            # your error handling here
            continue
    
for session in wrapper(parse_chatlog_multi(paths)):
    print(repr(session))
1 Like