pm4py.write module#

The pm4py.write module contains all functionality related to writing files/objects to disk.

pm4py.write.write_xes(log: EventLog | DataFrame, file_path: str, case_id_key: str = 'case:concept:name', extensions=None, encoding: str = 'utf-8', variant_str: str | None = None, **kwargs) None[source]#

Writes an event log to disk in the XES format (see xes-standard).

Parameters:
  • log – Log object (EventLog or pandas.DataFrame) that needs to be written to disk.

  • file_path – Target file path of the event log (.xes file) on disk.

  • case_id_key – Column key that identifies the case identifier.

  • extensions – Extensions defined for the event log.

  • variant_str – Variant to be used (default: line-by-line, r4pm/rustxes)

  • encoding – The encoding to be used (default: utf-8).

import pm4py

pm4py.write_xes(log, '<path_to_export_to>', case_id_key='case:concept:name')
pm4py.write.write_pnml(petri_net: PetriNet, initial_marking: Marking, final_marking: Marking, file_path: str, encoding: str = 'utf-8') None[source]#

Writes a Petri net object to disk in the .pnml format (see pnml-standard).

Parameters:
  • petri_net – Petri net object that needs to be written to disk.

  • initial_marking – Initial marking of the Petri net.

  • final_marking – Final marking of the Petri net.

  • file_path – Target file path on disk of the .pnml file.

  • encoding – The encoding to be used (default: utf-8).

import pm4py

pm4py.write_pnml(petri_net, initial_marking, final_marking, '<path_to_export_to>')
pm4py.write.write_ptml(tree: ProcessTree, file_path: str, auto_layout: bool = True, encoding: str = 'utf-8') None[source]#

Writes a process tree object to disk in the .ptml format.

Parameters:
  • tree – ProcessTree object that needs to be written to disk.

  • file_path – Target file path on disk of the .ptml file.

  • auto_layout – Boolean indicating whether the model should get an auto layout (which is written to disk).

  • encoding – The encoding to be used (default: utf-8).

import pm4py

pm4py.write_ptml(tree, '<path_to_export_to>', auto_layout=True)
pm4py.write.write_dfg(dfg: Dict[Tuple[str, str], int], start_activities: Dict[str, int], end_activities: Dict[str, int], file_path: str, encoding: str = 'utf-8') None[source]#

Writes a directly follows graph (DFG) object to disk in the .dfg format.

Parameters:
  • dfg – Directly follows relation (multiset of activity-activity pairs).

  • start_activities – Multiset tracking the number of occurrences of start activities.

  • end_activities – Multiset tracking the number of occurrences of end activities.

  • file_path – Target file path on disk to write the DFG object to.

  • encoding – The encoding to be used (default: utf-8).

import pm4py

pm4py.write_dfg(dfg, start_activities, end_activities, '<path_to_export_to>')
pm4py.write.write_bpmn(model: BPMN, file_path: str, auto_layout: bool = True, encoding: str = 'utf-8') None[source]#

Writes a BPMN model object to disk in the .bpmn format.

Parameters:
  • model – BPMN model to export.

  • file_path – Target file path on disk to write the BPMN object to.

  • auto_layout – Boolean indicating whether the model should get an auto layout (which is written to disk).

  • encoding – The encoding to be used (default: utf-8).

import pm4py

pm4py.write_bpmn(model, '<path_to_export_to>', auto_layout=True)
pm4py.write.write_ocel(ocel: OCEL, file_path: str, objects_path: str = None, encoding: str = 'utf-8') None[source]#

Writes an OCEL object to disk in various formats. Supported formats include CSV (flat table), JSON-OCEL, XML-OCEL, and SQLite (described on the site https://www.ocel-standard.org/).

Parameters:
  • ocel – OCEL object to write to disk.

  • file_path – Target file path on disk to write the OCEL object to.

  • objects_path – Location of the objects table (only applicable in case of .csv exporting).

  • encoding – The encoding to be used (default: utf-8).

import pm4py

pm4py.write_ocel(ocel, '<path_to_export_to>')
pm4py.write.write_ocel_csv(ocel: OCEL, file_path: str, objects_path: str, encoding: str = 'utf-8') None[source]#

Writes an OCEL object to disk in the .csv file format. The OCEL object is exported into two separate files, i.e., one event table and one objects table. Both file paths should be specified.

Parameters:
  • ocel – OCEL object.

  • file_path – Target file path on disk to write the event table to.

  • objects_path – Target file path on disk to write the objects table to.

  • encoding – The encoding to be used (default: utf-8).

import pm4py

pm4py.write_ocel_csv(ocel, '<path_to_export_events_to>', '<path_to_export_objects_to>')
pm4py.write.write_ocel_json(ocel: OCEL, file_path: str, encoding: str = 'utf-8') None[source]#

Writes an OCEL object to disk in the .jsonocel file format.

Parameters:
  • ocel – OCEL object.

  • file_path – Target file path on disk to write the OCEL object to.

  • encoding – The encoding to be used (default: utf-8).

import pm4py

pm4py.write_ocel_json(ocel, '<path_to_export_to>')
pm4py.write.write_ocel_xml(ocel: OCEL, file_path: str, encoding: str = 'utf-8') None[source]#

Writes an OCEL object to disk in the .xmlocel file format.

Parameters:
  • ocel – OCEL object.

  • file_path – Target file path on disk to write the OCEL object to.

  • encoding – The encoding to be used (default: utf-8).

import pm4py

pm4py.write_ocel_xml(ocel, '<path_to_export_to>')
pm4py.write.write_ocel_sqlite(ocel: OCEL, file_path: str, encoding: str = 'utf-8') None[source]#

Writes an OCEL object to disk to a SQLite database (exported as .sqlite file).

Parameters:
  • ocel – OCEL object.

  • file_path – Target file path to the SQLite database.

  • encoding – The encoding to be used (default: utf-8).

import pm4py

pm4py.write_ocel_sqlite(ocel, '<path_to_export_to>')
pm4py.write.write_ocel2(ocel: OCEL, file_path: str, encoding: str = 'utf-8') None[source]#

Writes an OCEL2.0 object to disk in various formats. Supported formats include JSON-OCEL, XML-OCEL, and SQLite.

Parameters:
  • ocel – OCEL object.

  • file_path – Target file path to write the OCEL2.0 object to.

  • encoding – The encoding to be used (default: utf-8).

import pm4py

pm4py.write_ocel2(ocel, '<path_to_export_to>')
pm4py.write.write_ocel2_json(ocel: OCEL, file_path: str, encoding: str = 'utf-8') None[source]#

Writes an OCEL2.0 object to disk in the .jsonocel file format.

Parameters:
  • ocel – OCEL object.

  • file_path – Target file path to the JSON-OCEL file.

  • encoding – The encoding to be used (default: utf-8).

import pm4py

pm4py.write_ocel2_json(ocel, '<path_to_export_to>')
pm4py.write.write_ocel2_sqlite(ocel: OCEL, file_path: str, encoding: str = 'utf-8') None[source]#

Writes an OCEL2.0 object to disk to a SQLite database (exported as .sqlite file).

Parameters:
  • ocel – OCEL object.

  • file_path – Target file path to the SQLite database.

  • encoding – The encoding to be used (default: utf-8).

import pm4py

pm4py.write_ocel2_sqlite(ocel, '<path_to_export_to>')
pm4py.write.write_ocel2_xml(ocel: OCEL, file_path: str, encoding: str = 'utf-8') None[source]#

Writes an OCEL2.0 object to disk in the .xmlocel file format.

Parameters:
  • ocel – OCEL object.

  • file_path – Target file path to the XML-OCEL file.

  • encoding – The encoding to be used (default: utf-8).

import pm4py

pm4py.write_ocel2_xml(ocel, '<path_to_export_to>')