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:

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

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")

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:

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")

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.

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.0a1.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.0a1-cp314-cp314-win_amd64.whl (2.4 MB view details)

Uploaded CPython 3.14Windows x86-64

triplets-0.2.0a1-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.0a1-cp314-cp314-macosx_11_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

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

Uploaded CPython 3.13Windows x86-64

triplets-0.2.0a1-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.0a1-cp313-cp313-macosx_11_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

triplets-0.2.0a1-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.0a1-cp312-cp312-macosx_11_0_arm64.whl (2.4 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

triplets-0.2.0a1-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.0a1-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.0a1.tar.gz.

File metadata

  • Download URL: triplets-0.2.0a1.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.0a1.tar.gz
Algorithm Hash digest
SHA256 3a46bc460ff58375944090d02f140bf3e2555331e4fa68fbb93c815c487bfc63
MD5 3bdd39955ac107a9b4822b77962426d7
BLAKE2b-256 179c68d19a32f67fc7cd6d176bebf40936e8ef47914a3d2faca170baf233fac2

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: triplets-0.2.0a1-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.0a1-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 89bf39c32e2c836de3a51c9f60313706c30bf68421e598b333220c8bf3692597
MD5 9dd5c372cfe51ccfb9ca01671d86916a
BLAKE2b-256 56663652ff6c14cfaee39be30bb44d45d5d972010993df978971a1de192cdbb3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for triplets-0.2.0a1-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6940eb845207019daee3c3f024f58cfa61b15844f716a66d39ecf574d6255e61
MD5 b0c6e72ff880b8aa4a53f6242eb16b66
BLAKE2b-256 67fbbacc4b2b7c43642700c195908b82112f2564c87a2628086a2c1ad6fc4a8a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for triplets-0.2.0a1-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f50eb197c62cd5882800249d608c19c85d325e249dce90ddf9ac3f383a00a804
MD5 09947d6415b298c7a764eaa3d9bcdb2c
BLAKE2b-256 79cd74caf837e31f7827dc73dea669bce4aa73a6019a61e1be94917d8ed1af55

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: triplets-0.2.0a1-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.0a1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 f7f29e2ea7e6448db9787c8ea8448c56435ac095a8b9da067597a93b0905c5c1
MD5 216e6bf2b53b7495fcdabf3823e1cc44
BLAKE2b-256 9a8feb458a65feecf0a8cfa387e3b14872ae512f445233407e51608a924d6417

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for triplets-0.2.0a1-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7bc8c74fece6f90d2c3e7c47572bb7237ef59c71d51c4e63215b6d2a8e352e7f
MD5 060173a984aea3ed531d439703f1e096
BLAKE2b-256 6a6a19dd4f48276ec8b4320ab7b3996e129b5360ed431ff43d9a63c902761af2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for triplets-0.2.0a1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a77c7f962a4843c2607863c00a5749877c931d6e1e3014b540a0347f03e1d833
MD5 3f07fe6d0f646afb483d173bba153860
BLAKE2b-256 9c9273d8d9253cc933fb5a24bf53ecc92fd9817dd4e069644ee77a18496b6456

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: triplets-0.2.0a1-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.0a1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 512436d33c51edda0ecc1821243d2a65a3a6afd1baa2a1a3d9bd8df1f0753110
MD5 e64a03e7c440c2141c3502749ba8bfb9
BLAKE2b-256 55235cb47d470b26a19c13bb20d7a28771504836cd537c3b4a1d40816765cd69

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for triplets-0.2.0a1-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e47913b92f79ccc927138a3eeb13a01ff37ba271e0101c171fd86abfd64753c3
MD5 16aac8dc2c287d0f27eaae48405503c7
BLAKE2b-256 d297fe9379e95b0a7a3a8386b04542410a9babc5e3c0ec4c010b545d24f43136

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for triplets-0.2.0a1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2bd60eca7834e931a5c62f2b5462d90c3e8c57eff5f0cc11ecf3829596412201
MD5 dca62daa5c272d7f4ffe852ed8278323
BLAKE2b-256 be99384809e16158e7ec4aafda5ea92e403d789dd89d2f17f552e8032af7ae42

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: triplets-0.2.0a1-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.0a1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 5046c7907d2c3e2d6074e131b2ffb531fd348a7e3a9e081b2e01fa16280e0fa5
MD5 7dc670a87718e720016a76ea7bb8c0f9
BLAKE2b-256 30fc0355dda04342d2274d26a07dfe6e845c3000c8dbeeff92d270b1d5495def

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for triplets-0.2.0a1-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d147a5347228dc71a291c0ce391752bf22d6ed2b61dd4987cdc9bb07939a69cf
MD5 0a45bba51718d4c9944a4a5bfce657a0
BLAKE2b-256 27fc257bf9487bf4fd7d30bff08b8d6349ec58d16c6c4675f5de62adffaa73e0

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for triplets-0.2.0a1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b5a49ab5245b74772e84cfdf5d58b8a8aaf8cbe1bd46d86a88d39c6bdb774cf3
MD5 fcdee0db163be8ecfacdeb8563859b05
BLAKE2b-256 b7524505052541c9b5419e32ecbcacf64dd86dfcd0349dd7edf07b7f3449a069

See more details on using hashes here.

Provenance

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