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, ~10x faster)
pip install triplets[arrow]

Install extras by feature:

Extra Enables
arrow compiled Arrow parser engines (~10x 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) ~10x 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.

Engine selection is automatic across the library (parser, exports, SPARQL, validation): installing an extra makes everything that can use it faster, with no code changes. Inspect and steer it globally:

triplets.engines()                        # what "auto" resolved to, per subsystem
triplets.set_engine(parser_cimxml="python_lxml_pandas", sparql="rdflib")
triplets.set_engine(parser_cimxml="auto") # restore auto-selection

Per-call engine= arguments always win over set_engine. Operations on your DataFrame itself (filters, tableviews, references) always run in the engine of the object you call them on — pandas frames stay pandas, polars stays polars.

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()                              # default table "triplets"
data = duckdb.connect("grid.duckdb", table="grid", schema="cim")  # per-connection defaults
# explicit table/schema config is stored in the database file — reopening
# duckdb.connect("grid.duckdb") later resolves cim.grid automatically

data.read_rdf(["grid_EQ.xml", "data.zip"])           # streams into the connection's table
data.read_rdf(["update.zip"], append=True)           # adds rows instead of replacing
data.get_types_count()                               # uses connection table/schema
data.tableview_by_type("ACLineSegment").df()
data.filter_triplets(KEY="Type", VALUE=".*Sub.*", regex=True).df()
data.references_to("some-uuid").df()
data.export_to_nquads("/tmp/output.nq")

# Per-call override; rebind defaults with set_triplets_table(...)
data.types_dict(table="other", schema="main")

# Direct SQL (your identifiers — tools always quote theirs)
data.sql('SELECT VALUE, COUNT(*) FROM "cim"."grid" 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 — format from path suffix (or format=)
violations.shacl.to_shacl_report(path="report.ttl")
violations.shacl.to_shacl_report(path="report.xml", report_source="model.xml",
                                 report_references=["equipment.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)

Committed benchmark results live in tests/performance_results/; re-run with pytest -m performance. Representative numbers (cython parse 1.47s → 0.157s vs the lxml engine = ~9.4x):

Operation pandas polars DuckDB
Parse (cython engine) 157ms 180ms streams (see duckdb section)
tableview_by_type 72ms 15ms 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.0rc6.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.0rc6-cp314-cp314-win_amd64.whl (2.5 MB view details)

Uploaded CPython 3.14Windows x86-64

triplets-0.2.0rc6-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (5.1 MB view details)

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

triplets-0.2.0rc6-cp314-cp314-macosx_11_0_arm64.whl (2.5 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

triplets-0.2.0rc6-cp313-cp313-win_amd64.whl (2.5 MB view details)

Uploaded CPython 3.13Windows x86-64

triplets-0.2.0rc6-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (5.1 MB view details)

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

triplets-0.2.0rc6-cp313-cp313-macosx_11_0_arm64.whl (2.5 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

triplets-0.2.0rc6-cp312-cp312-win_amd64.whl (2.5 MB view details)

Uploaded CPython 3.12Windows x86-64

triplets-0.2.0rc6-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (5.1 MB view details)

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

triplets-0.2.0rc6-cp312-cp312-macosx_11_0_arm64.whl (2.5 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

triplets-0.2.0rc6-cp311-cp311-win_amd64.whl (2.5 MB view details)

Uploaded CPython 3.11Windows x86-64

triplets-0.2.0rc6-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (5.2 MB view details)

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

triplets-0.2.0rc6-cp311-cp311-macosx_11_0_arm64.whl (2.5 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for triplets-0.2.0rc6.tar.gz
Algorithm Hash digest
SHA256 ed733a7074cbb383d7e9fd6d860d5b18e34675d96d63afed040f98e4c5f9da77
MD5 08fdcc23efc9fed98ae2c36863fea9c9
BLAKE2b-256 7d0d6151b6ac7a3f27e42b8e33380f8bc5c04e8a4bd6490da8fbc466a3a210a3

See more details on using hashes here.

Provenance

The following attestation bundles were made for triplets-0.2.0rc6.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.0rc6-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for triplets-0.2.0rc6-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 0ec9dd1bdad4f7ab788e6c92a0108f00f35ef9baa678f3d69e4c0a44cd4a1dd2
MD5 ecd9d109a2b2525bfcdcd81d906bb3d9
BLAKE2b-256 f11d95b622b4b9fd369efeb6c049aa6a943257d0bbfaba1fdb2ada6e53f7d593

See more details on using hashes here.

Provenance

The following attestation bundles were made for triplets-0.2.0rc6-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.0rc6-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for triplets-0.2.0rc6-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 bacbb329d7b331ec9da680591e180be0f7eaa6606f8b957fdf52ef3e0a7b277f
MD5 2130fd2f040cc3802438a9a13a940313
BLAKE2b-256 5fa45ec1eb55faeda201f49fbb384ca9051c43fd6a168459ba6870c9729ebff6

See more details on using hashes here.

Provenance

The following attestation bundles were made for triplets-0.2.0rc6-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.0rc6-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for triplets-0.2.0rc6-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 20ff503a269689dc767635d8dc1f552445ecaba645e7cc1c247fb020541cfa1d
MD5 6998de82a93c42d0fdf0bc2943e21814
BLAKE2b-256 9857728a77ceee8e3a4a38b9eb3755a867f96c1d52af8b3c22cd0de19d87d277

See more details on using hashes here.

Provenance

The following attestation bundles were made for triplets-0.2.0rc6-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.0rc6-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for triplets-0.2.0rc6-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 4f4aa2f250e26f1b75c59bf20251aa735969e4a13eb49c9d8b1a013c1c3653b7
MD5 76aad74fc9ff7287328440ac001ebb17
BLAKE2b-256 707df06c2abd6b2e8da1ed2ebaba6e3873425580cf007f4d9612ca0808a2efae

See more details on using hashes here.

Provenance

The following attestation bundles were made for triplets-0.2.0rc6-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.0rc6-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for triplets-0.2.0rc6-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ae2a31a1cb5d55ae2d6efc295c25c254f53bf593f5b78f19102798270b09123b
MD5 272b0d9fc57084b165ee6d16f159f3e2
BLAKE2b-256 a4546e8f38428c19d6db4d3f49f12fe32b4371f4816aa6b473b3b78105d5bf4b

See more details on using hashes here.

Provenance

The following attestation bundles were made for triplets-0.2.0rc6-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.0rc6-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for triplets-0.2.0rc6-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cdb195e676f87a2ba8d7da2fdd39f3dd8225b67b2d521850315f8ef2f27405a0
MD5 dba6dd99ab65a6d158f6ad38a44bf678
BLAKE2b-256 1d3e7b5d9e8a633a3e309b03286b8871527f95d47def8cf04caf1598998ee2af

See more details on using hashes here.

Provenance

The following attestation bundles were made for triplets-0.2.0rc6-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.0rc6-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for triplets-0.2.0rc6-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 8d4676bf9f52af88a7a6ced03a02a1411d805773cea4f8a9ad96c10bb173f051
MD5 98aee243344013c4edc193d3b006b24a
BLAKE2b-256 6bc5c9a4ef23ac4fcc612c612cc725bebfbc8c1f69f3824b52dddf2ac7d4f741

See more details on using hashes here.

Provenance

The following attestation bundles were made for triplets-0.2.0rc6-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.0rc6-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for triplets-0.2.0rc6-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1e781b7a00f854eb1dd0d1edde61147db73b0523648cd1dc40226326c3988ed0
MD5 f0e0340c146274fdecc5d1073f97306d
BLAKE2b-256 33444791f5116bdfb0c573ce99132f15366b6ce9ac90d3945e1de22c22be9191

See more details on using hashes here.

Provenance

The following attestation bundles were made for triplets-0.2.0rc6-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.0rc6-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for triplets-0.2.0rc6-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e5685a2db4325f2349405fedcb3dda108c49513bfe48e440d9d65e32eed31f16
MD5 c6171373c386fc0c5c389dc00ca43615
BLAKE2b-256 12b3e17e6452a5802332ccc8ed4ba58b2abca703c0fbe925d3ab91349e533ab9

See more details on using hashes here.

Provenance

The following attestation bundles were made for triplets-0.2.0rc6-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.0rc6-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for triplets-0.2.0rc6-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 df2605197f897face33aa25af246af80207f0e7654e27238f58f3883e33fe90a
MD5 a9d3028a7f0619d421b4504a80432c11
BLAKE2b-256 00829617ef7f0b70ff9261596bdd9494ef5c10a0025696d5f01c1cdbfa5bfc22

See more details on using hashes here.

Provenance

The following attestation bundles were made for triplets-0.2.0rc6-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.0rc6-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for triplets-0.2.0rc6-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c345f7a7d6bac44b529ecc9de8bad65b76340e716ac521050a87273c50933deb
MD5 55272b522871e4f78a2285e3439308d3
BLAKE2b-256 f4b4f4c0105c5c2be3596215eb5eb6cb3ad09f0ff68ab3a1de385d2b211b9cf3

See more details on using hashes here.

Provenance

The following attestation bundles were made for triplets-0.2.0rc6-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.0rc6-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for triplets-0.2.0rc6-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7172c24a3be6df1e84062ff8231a3410d983eb844d488a86d24671a119cb18f5
MD5 768084ce3160c2f41a6c6312222b6d3c
BLAKE2b-256 4ac20ed91ea577b07977adeb34fa4a00acf9a0f5f52f0318ab1dfbbae4f82498

See more details on using hashes here.

Provenance

The following attestation bundles were made for triplets-0.2.0rc6-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.0rc6 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