Skip to content

Commit

Permalink
Merge branch 'PMPY-2000' into 'integration'
Browse files Browse the repository at this point in the history
PMPY-2000 Flag to return EventLog object from pm4py.read_xes method

Closes PMPY-2000

See merge request process-mining/pm4py/pm4py-core!894
  • Loading branch information
fit-sebastiaan-van-zelst committed Jan 6, 2023
2 parents 9186c5b + 733b26d commit 63371db
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pm4py/read.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from pandas import DataFrame
import pkgutil
import deprecation
from typing import Union

INDEX_COLUMN = "@@index"

Expand All @@ -22,13 +23,14 @@
"""


def read_xes(file_path: str, variant: str = "lxml", **kwargs) -> DataFrame:
def read_xes(file_path: str, variant: str = "lxml", return_legacy_log_object: bool = False, **kwargs) -> Union[DataFrame, EventLog]:
"""
Reads an event log stored in XES format (see `xes-standard <https://xes-standard.org/>`_)
Returns a table (``pandas.DataFrame``) view of the event log.
:param file_path: file path of the event log (``.xes`` file) on disk
:param variant: the variant of the importer to use. "iterparse" => traditional XML parser; "line_by_line" => text-based line-by-line importer ; "chunk_regex" => chunk-of-bytes importer (default); "iterparse20" => XES 2.0 importer
:param return_legacy_log_object: boolean value enabling returning a log object (default: False)
:rtype: ``DataFrame``
.. code-block:: python3
Expand All @@ -52,6 +54,8 @@ def read_xes(file_path: str, variant: str = "lxml", **kwargs) -> DataFrame:
elif variant == "chunk_regex":
v = xes_importer.Variants.CHUNK_REGEX
log = xes_importer.apply(file_path, variant=v, parameters=kwargs)
if return_legacy_log_object:
return log
log = log_converter.apply(log, variant=log_converter.Variants.TO_DATA_FRAME)
log = dataframe_utils.convert_timestamp_columns_in_df(log)
return log
Expand Down

0 comments on commit 63371db

Please sign in to comment.