Download scripts/mining/xes_to_parquet.py from NovaeonStudio/p2p-process-models-bpmn: direct link, hf CLI and curl.
- Browser
- Download file 1.47 kB
-
https://huggingface.co/datasets/NovaeonStudio/p2p-process-models-bpmn/resolve/main/scripts/mining/xes_to_parquet.py
- Command line
-
hf download hf://datasets/NovaeonStudio/p2p-process-models-bpmn/scripts/mining/xes_to_parquet.py
-
curl -L -o xes_to_parquet.py https://huggingface.co/datasets/NovaeonStudio/p2p-process-models-bpmn/resolve/main/scripts/mining/xes_to_parquet.py
1.47 kB
| # SPDX-License-Identifier: MIT - Copyright (c) 2026 Novaeon | |
| """Streaming-Konvertierung BPIC 2019 XES -> Parquet (stdlib iterparse, wenig RAM).""" | |
| import sys, xml.etree.ElementTree as ET, pandas as pd | |
| src, dst = sys.argv[1], sys.argv[2] | |
| NS = "{http://www.xes-standard.org/}" | |
| rows, trace_attrs, in_trace = [], {}, False | |
| def attrs(el): | |
| return {c.get("key"): c.get("value") for c in el if c.tag.split("}")[-1] in ("string", "date", "float", "int", "boolean")} | |
| for ev, el in ET.iterparse(src, events=("start", "end")): | |
| tag = el.tag.split("}")[-1] | |
| if ev == "start" and tag == "trace": in_trace, trace_attrs = True, None | |
| elif ev == "end" and tag == "event" and in_trace: | |
| a = attrs(el); a["_event"] = True; rows.append(a); el.clear() | |
| elif ev == "end" and tag == "trace": | |
| t = attrs(el) | |
| # Trace-Attribute nachtragen (Events dieser Trace sind die letzten ohne 'case:concept:name') | |
| i = len(rows) - 1 | |
| while i >= 0 and "case:concept:name" not in rows[i]: | |
| for k, v in t.items(): rows[i]["case:" + k] = v | |
| i -= 1 | |
| el.clear(); in_trace = False | |
| df = pd.DataFrame(rows).drop(columns=["_event"]) | |
| df["time:timestamp"] = pd.to_datetime(df["time:timestamp"], utc=True, format="ISO8601") | |
| if "Cumulative net worth (EUR)" in df: df["Cumulative net worth (EUR)"] = pd.to_numeric(df["Cumulative net worth (EUR)"], errors="coerce") | |
| df.to_parquet(dst, index=False) | |
| print(df.shape); print(df.columns.tolist()) | |