Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

About:

  • Parses CIM RDF/XML data to pandas dataframe with 4 columns [ID, KEY, VALUE, INSTANCE_ID] (triplestore like)
  • The solution does not care about CIM version nor namespaces
  • Input files can be xml or zip files (containing one or mutiple xml files)
  • All files are parsed into one and same Pandas DataFrame, thus if you want single file or single data model, you need to filter on INSTANCE_ID column

Documentation:

https://haigutus.github.io/triplets

Upgrading from 0.0.x? See docs/migration_0.0_to_0.1.md.

To get started:

# Core (python_lxml_pandas engine, no extra deps)
pip install triplets

# With pyarrow (enables python_lxml_arrow + cython_pugixml_arrow engines, ~12x faster)
pip install triplets[arrow]

Install extras by feature:

Extra Enables
arrow compiled Arrow parser engines (~12x faster parsing)
polars polars DataFrames (polars.read_rdf, .triplets namespace)
duckdb DuckDB connections (con.read_rdf, SQL over triplets)
sparql SPARQL queries (rdflib reference engine)
oxigraph recommended pip performance path — embedded Rust SPARQL engine (auto-preferred over rdflib)
validation SHACL validation (pyshacl reference engine)
excel / networkx / visualization Excel export / graph export / drawing

The embedded qlever SPARQL engine (fastest) ships in no wheel — it is a local source build, see docs/building.md.

import pandas
import triplets

path = "CGMES_v2.4.15_RealGridTestConfiguration_v2.zip"
data = pandas.read_RDF([path])

Result:

image

You can then query a dataframe of all same type elements and its parameters across all [EQ, SSH, TP, SV etc.] instance files, where parameters are columns and index is object ID-s

data.tableview_by_type("ACLineSegment")

image

Export:

from triplets.export_schema import schemas
from triplets.export import ExportType

data.export_to_cimxml(
    rdf_map=schemas.ENTSOE_CGMES_2_4_15_552_ED1,
    export_type=ExportType.XML_PER_INSTANCE_ZIP_PER_XML,
)

Export schemas are versioned and shipped per profile. Alongside the CGMES bundles (schemas.ENTSOE_CGMES_2_4_15_552_ED1, schemas.ENTSOE_CGMES_3_0_0_552_ED1, …) the versioned NC (Network Code) profiles are available as schemas.ENTSOE_NC_2_4_1_552_ED1 / schemas.ENTSOE_NC_2_4_1_552_ED2. The _ED1 / _ED2 suffix selects the serialization edition; profile resolution is schema-driven, so the right profile section is matched from the instance header.

Look into examples folders for more

Parser engines

Three parser engines with automatic fallback (fastest available):

Engine Install Speed
python_lxml_pandas pip install triplets 1x baseline, always works
python_lxml_arrow pip install triplets[arrow] ~1x, better interop
cython_pugixml_arrow pip install triplets[arrow] (included in wheels) 12x faster

The cython_pugixml_arrow engine is a compiled C++ extension included in published wheels. It requires pyarrow at runtime, so install with triplets[arrow] to enable it.

The cython engine is pre-built in published wheels — no compilation needed.

Polars

import polars
import triplets

data = polars.read_rdf(["grid_EQ.xml", "data.zip"])   # returns polars DataFrame

data.triplets.get_types_count()
data.triplets.tableview_by_type("ACLineSegment")
data.triplets.filter_triplets(KEY="Type", VALUE=".*Generator.*", regex=True)
data.triplets.export_to_csv(export_to_memory=True)
data.triplets.export_to_nquads("/tmp/output.nq")
data = polars.read_nquads("/tmp/output.nq")           # round-trips N-Quads back to triplets

read_nquads is registered as pandas.read_nquads / polars.read_nquads and is also exposed top-level as triplets.read_nquads.

DuckDB

import duckdb
import triplets

data = duckdb.connect()                              # in-memory
data = duckdb.connect("grid.duckdb")                 # persistent (no re-parsing next session)

data.read_rdf(["grid_EQ.xml", "data.zip"])           # parse via Arrow (zero-copy into DuckDB)
data.get_types_count()                                     # → dict
data.tableview_by_type("ACLineSegment").df()             # → pandas DataFrame
data.tableview_by_type("ACLineSegment").pl()             # → polars DataFrame
data.filter_triplets(KEY="Type", VALUE=".*Sub.*", regex=True).df()
data.filter_triplets_by_type("Terminal").df()
data.references_to("some-uuid").df()
data.export_to_nquads("/tmp/output.nq")

# Direct SQL (full DuckDB SQL on the triplets table)
data.sql("SELECT VALUE, COUNT(*) FROM triplets WHERE KEY = 'Type' GROUP BY VALUE").df()

# The same tools are also on the `.triplets` namespace (parity with pandas/polars)
data.triplets.tableview_by_type("ACLineSegment").df()
data.triplets.get_types_count()

SPARQL queries

SPARQL 1.1 over the loaded data — SELECT → DataFrame, ASK → bool, CONSTRUCT → triplet DataFrame. Works on pandas, polars and DuckDB inputs:

PREFIXES = """
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX cim: <http://iec.ch/TC57/CIM100#>
"""
names = data.sparql.query(PREFIXES + "SELECT ?s ?name WHERE { ?s cim:IdentifiedObject.name ?name }")

Three engines behind one API (auto picks the fastest available):

Engine Install Role
qlever local source build (docs/building.md) fastest — embedded C++, persistent on-disk index
oxigraph pip install triplets[oxigraph] embedded Rust — ~3x faster import, 2–5x faster queries than rdflib
rdflib pip install triplets[sparql] pure-Python reference

Details and measured numbers: docs/sparql.md.

SHACL validation

Validate against SHACL shape files; the result is a violations DataFrame (empty = conforms) with the same shape across all engines:

from triplets.export_schema import schemas

violations = data.shacl.validate("shapes.ttl", rdf_map=schemas.ENTSOE_CGMES_3_0_0_552_ED1)

# slower optional context pass: source file, object type/name,
# shape sh:name/sh:description, schema attribute/class definitions
violations = data.shacl.validate(shapes, context=True)

# SARIF 2.1.0 for GitHub / SonarQube / any SARIF viewer — grouped by default
# (one result per rule with occurrenceCount + sample instances)
violations.shacl.to_sarif(path="report.sarif")

# standard SHACL sh:ValidationReport (Turtle) for any SHACL-aware tooling
violations.shacl.to_shacl_report(path="report.ttl")

Engines: polars (auto, real profiles in ~2 s) → pandaspyshacl (reference); duckdb for larger-than-memory data. sh:sparql constraints ride the SPARQL engine above (minutes → milliseconds with oxigraph/qlever). Details: docs/validation.md.

Accessor namespace

pandas and polars DataFrames use df.triplets.*; a DuckDB connection uses con.triplets.*. The same method names are available on both (DuckDB returns relations — add .df() or .pl() when needed):

# pandas / polars
df.triplets.tableview_by_type("ACLineSegment")
df.triplets.export_to_nquads("/tmp/output.nq")

# DuckDB
con.triplets.tableview_by_type("ACLineSegment").df()
con.triplets.get_types_count()

Root-level methods (df.type_tableview(...), con.filter_triplets(...)) still work for backwards compatibility.

Cache lifecycle

Engines keep internal state (compiled shapes, SPARQL indexes) cached across calls. Reset it explicitly with triplets.clear_caches(), or scope it to a block so it is cleared on exit:

import triplets

with triplets.cache_scope():
    ...            # caches populated here are dropped when the block exits

triplets.clear_caches()   # or clear everything manually

CLI tools

cim-spreadsheet -i model.xml -o output.xlsx
cim-diff original.xml modified.xml

Performance (RealGrid, 1.14M rows)

Operation pandas polars DuckDB
Parse (cython engine) 128ms 156ms 283ms
tableview_by_type 72ms 21ms 53ms
filter_triplets_by_type 103ms 9ms 50ms
get_types_count 21ms 11ms 18ms

The old rdf_parser.py functions still work but emit deprecation warnings. See docs/migration_0.0_to_0.1.md for renames and breaking changes.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

triplets-0.2.0a2.tar.gz (2.7 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

triplets-0.2.0a2-cp314-cp314-win_amd64.whl (2.4 MB view details)

Uploaded CPython 3.14Windows x86-64

triplets-0.2.0a2-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (5.0 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

triplets-0.2.0a2-cp314-cp314-macosx_11_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

triplets-0.2.0a2-cp313-cp313-win_amd64.whl (2.4 MB view details)

Uploaded CPython 3.13Windows x86-64

triplets-0.2.0a2-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (5.0 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

triplets-0.2.0a2-cp313-cp313-macosx_11_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

triplets-0.2.0a2-cp312-cp312-win_amd64.whl (2.4 MB view details)

Uploaded CPython 3.12Windows x86-64

triplets-0.2.0a2-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (5.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

triplets-0.2.0a2-cp312-cp312-macosx_11_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

triplets-0.2.0a2-cp311-cp311-win_amd64.whl (2.4 MB view details)

Uploaded CPython 3.11Windows x86-64

triplets-0.2.0a2-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (5.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

triplets-0.2.0a2-cp311-cp311-macosx_11_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

Details for the file triplets-0.2.0a2.tar.gz.

File metadata

  • Download URL: triplets-0.2.0a2.tar.gz
  • Upload date:
  • Size: 2.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for triplets-0.2.0a2.tar.gz
Algorithm Hash digest
SHA256 1deef4ad38b2f93238e1182109f0d1521e6a6d1ce78d6df605561576a9631c77
MD5 e412bf61f370e47a5856791f596c359f
BLAKE2b-256 bf02cced8a2efcfc95830f7df5aec71913d903fa255af6238d8eb05eb5410ccb

See more details on using hashes here.

Provenance

The following attestation bundles were made for triplets-0.2.0a2.tar.gz:

Publisher: build-wheels.yml on Haigutus/triplets

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file triplets-0.2.0a2-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: triplets-0.2.0a2-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 2.4 MB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for triplets-0.2.0a2-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 ecda2a87cf324052aad703828f341ff9e4c5cea3da7d41a2cf161a4429d4d3de
MD5 9ca4a0e5658619bd3757977326281bb6
BLAKE2b-256 c00a15f9c8483456d3e8b4f32d27f73f4d2d6a54dec1d6b5c61ba142901ba5b1

See more details on using hashes here.

Provenance

The following attestation bundles were made for triplets-0.2.0a2-cp314-cp314-win_amd64.whl:

Publisher: build-wheels.yml on Haigutus/triplets

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file triplets-0.2.0a2-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for triplets-0.2.0a2-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c8d10fa6741b604bc77f2c644d74e97011eef4b42a9927d1f3e7eeb93ab5a45f
MD5 b4f9ab4f6a91cafba022022f448d8c7d
BLAKE2b-256 6d959da2d5fbd416ec9420e1e266faba96d6967fbe1b11beabc079ec15beb2e4

See more details on using hashes here.

Provenance

The following attestation bundles were made for triplets-0.2.0a2-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build-wheels.yml on Haigutus/triplets

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file triplets-0.2.0a2-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for triplets-0.2.0a2-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 74f81075e30d2acca60b24ce8d1a3d8eb4166664590ccf5a016b58ef4ccb50be
MD5 e4a7d166afe39b27e1c5fab5282571bd
BLAKE2b-256 e17f7abeaaed22e44c3d472e5bcd8f797d30c8bacc0465a49b14a23d8658c51c

See more details on using hashes here.

Provenance

The following attestation bundles were made for triplets-0.2.0a2-cp314-cp314-macosx_11_0_arm64.whl:

Publisher: build-wheels.yml on Haigutus/triplets

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file triplets-0.2.0a2-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: triplets-0.2.0a2-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 2.4 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for triplets-0.2.0a2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 cf0b52ca1c27b6bfb0182bc492d46a2403beb66b1dd2c72dfa1ff396778b0d53
MD5 9adac509feabf18126615f4473935c6a
BLAKE2b-256 373c52e5793ceefa2e76854d096b2e28451647d0d4862a810f73436c0af228c1

See more details on using hashes here.

Provenance

The following attestation bundles were made for triplets-0.2.0a2-cp313-cp313-win_amd64.whl:

Publisher: build-wheels.yml on Haigutus/triplets

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file triplets-0.2.0a2-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for triplets-0.2.0a2-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 609e60531cf44212f3450fc9a8c53511c6f9d0f14e5b2cd88c3bb789e9c5e2f5
MD5 b3c8e13f6d5b70b0dcdd611f0bef46b7
BLAKE2b-256 bc623a33ba4ea0848fb1ba78101f33223b09e3b9d7c0165279eaf6f0a322069e

See more details on using hashes here.

Provenance

The following attestation bundles were made for triplets-0.2.0a2-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build-wheels.yml on Haigutus/triplets

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file triplets-0.2.0a2-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for triplets-0.2.0a2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8ec8a194f0779096fe450fc5b14dcbc6e6a8623e163e912db85c864313f4b786
MD5 e82cba1c653d12b8fd8ce4287487c661
BLAKE2b-256 a7b8cb2f60348b97cf00a3c318e8b7f187e3e868b3c3dfa7c11a67b65b004fce

See more details on using hashes here.

Provenance

The following attestation bundles were made for triplets-0.2.0a2-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: build-wheels.yml on Haigutus/triplets

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file triplets-0.2.0a2-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: triplets-0.2.0a2-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 2.4 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for triplets-0.2.0a2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 0eff469bc736125c0db85ffedfc94451ba187acb206454d81dacfa086fa6adbd
MD5 66fe1ba9ad01287879070a476fdff70e
BLAKE2b-256 e6550a7838e51846382bd58384ba4e78b82ec4bab2ba21cc6fcdc48e1c4229bd

See more details on using hashes here.

Provenance

The following attestation bundles were made for triplets-0.2.0a2-cp312-cp312-win_amd64.whl:

Publisher: build-wheels.yml on Haigutus/triplets

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file triplets-0.2.0a2-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for triplets-0.2.0a2-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d05e54d16d9d7af42d953cab910b75cce91c660415fa41eb7acc0eb7b58ac00e
MD5 c36be0b7c15972dd900cc96e448c1a51
BLAKE2b-256 69b413579616955866882f0c029c195ae756d5f84eabdf8096747978d1418fd2

See more details on using hashes here.

Provenance

The following attestation bundles were made for triplets-0.2.0a2-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build-wheels.yml on Haigutus/triplets

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file triplets-0.2.0a2-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for triplets-0.2.0a2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d8f4b79a34411bb3c8fcdf3a6e99a7319afa57a83196cf36ed69ce1994ed46d0
MD5 e1c6094ec1d19181e174cf506c11278f
BLAKE2b-256 016da304289205efa781ce67823f900e81991650a37c7c9d95d3de1f767872c4

See more details on using hashes here.

Provenance

The following attestation bundles were made for triplets-0.2.0a2-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: build-wheels.yml on Haigutus/triplets

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file triplets-0.2.0a2-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: triplets-0.2.0a2-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 2.4 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for triplets-0.2.0a2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 edef558b4624e6602cde5298e05e84c254106123e11db24ffcf69c5d5584da88
MD5 15c1ba6171bbd2cb9ea985f870c0e26a
BLAKE2b-256 ada48337d5a7ff489842ee54e6d25faf0264e9c8b7096f6306e64f4aff782f02

See more details on using hashes here.

Provenance

The following attestation bundles were made for triplets-0.2.0a2-cp311-cp311-win_amd64.whl:

Publisher: build-wheels.yml on Haigutus/triplets

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file triplets-0.2.0a2-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for triplets-0.2.0a2-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 43dfa417794e1acad126ca86fda50c8fd2d3b0e3fe21b5d09014987d31b8ff44
MD5 35cab660280f8507953ebc6c78ca1d6e
BLAKE2b-256 d769833359b4ad0d99d2816d272999b81bea707d8a5e57a031593bef17d9d277

See more details on using hashes here.

Provenance

The following attestation bundles were made for triplets-0.2.0a2-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build-wheels.yml on Haigutus/triplets

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file triplets-0.2.0a2-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for triplets-0.2.0a2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 99798b3feb3e4d193dac77100545e6bb574fbe9928123238d921f1ff31918513
MD5 f57b97344e08917481e1d71266d4621b
BLAKE2b-256 0da992f910e045af3a7488a7457829665d8fbd32ba684b47702170f06dec7f87

See more details on using hashes here.

Provenance

The following attestation bundles were made for triplets-0.2.0a2-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: build-wheels.yml on Haigutus/triplets

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.2.0

13 files

This release

0.2.0a2 This release

13 files

0.1.0

10 files

0.1.0rc2

12 files

0.0.17

2 files

0.0.16

2 files

0.0.15

2 files

0.0.14

2 files

0.0.13

2 files

0.0.12

2 files

0.0.11

2 files

0.0.10

2 files

0.0.9

2 files

0.0.8

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page