Skip to main content

No project description provided

Project description

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

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]
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.type_tableview("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.types_dict()
data.triplets.type_tableview("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.types_dict()                                     # → dict
data.type_tableview("ACLineSegment").df()             # → pandas DataFrame
data.type_tableview("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()

Accessor namespace

All engines share the same df.triplets.* accessor:

data.triplets.type_tableview("ACLineSegment")
data.triplets.types_dict()
data.triplets.filter_triplets(KEY="Type")
data.triplets.export_to_excel(export_to_memory=True)
data.triplets.export_to_nquads("/tmp/output.nq")

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
type_tableview 72ms 21ms 53ms
filter_triplets_by_type 103ms 9ms 50ms
types_dict 21ms 11ms 18ms

The old rdf_parser.py functions still work but emit deprecation warnings.

Project details


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.1.0rc4.tar.gz (2.5 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.1.0rc4-cp313-cp313-win_amd64.whl (2.3 MB view details)

Uploaded CPython 3.13Windows x86-64

triplets-0.1.0rc4-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (4.8 MB view details)

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

triplets-0.1.0rc4-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (4.7 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.24+ ARM64manylinux: glibc 2.28+ ARM64

triplets-0.1.0rc4-cp313-cp313-macosx_11_0_arm64.whl (2.3 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

triplets-0.1.0rc4-cp312-cp312-win_amd64.whl (2.3 MB view details)

Uploaded CPython 3.12Windows x86-64

triplets-0.1.0rc4-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (4.8 MB view details)

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

triplets-0.1.0rc4-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (4.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.24+ ARM64manylinux: glibc 2.28+ ARM64

triplets-0.1.0rc4-cp312-cp312-macosx_11_0_arm64.whl (2.3 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

triplets-0.1.0rc4-cp311-cp311-win_amd64.whl (2.3 MB view details)

Uploaded CPython 3.11Windows x86-64

triplets-0.1.0rc4-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (4.8 MB view details)

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

triplets-0.1.0rc4-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (4.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.24+ ARM64manylinux: glibc 2.28+ ARM64

triplets-0.1.0rc4-cp311-cp311-macosx_11_0_arm64.whl (2.3 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

Details for the file triplets-0.1.0rc4.tar.gz.

File metadata

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

File hashes

Hashes for triplets-0.1.0rc4.tar.gz
Algorithm Hash digest
SHA256 956b8ee53e8ad4d08d72a2e7cb3de1dd575d982fb26fe4a66566617fe8a7067d
MD5 af142d0228e7ebd8d6d65265923c20d9
BLAKE2b-256 5dd48fb2c49b29b54adb1fa26a1af0faa2bb64086f7330c56b9640aad2beac86

See more details on using hashes here.

Provenance

The following attestation bundles were made for triplets-0.1.0rc4.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.1.0rc4-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for triplets-0.1.0rc4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 f4b0de26da0e93367df118612c38f6856e5e6148a54590d25ad50718d434577a
MD5 1c4206438dac5d8668e4fb6b0fe57b88
BLAKE2b-256 964b8253047714d02316e6c827d8675b2050fcc83c5b7f0840ed689e520256a7

See more details on using hashes here.

Provenance

The following attestation bundles were made for triplets-0.1.0rc4-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.1.0rc4-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for triplets-0.1.0rc4-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 85046c171f4e11f62055b4c88dad2701d7c20d26f21ee89ee209a144a3337189
MD5 1887270b877ee2e6d55c22847401d4af
BLAKE2b-256 6dabc5c30c740e0fc0c1a2242a9de21fa51e42280b99d4e6c81bcb0446b4bb26

See more details on using hashes here.

Provenance

The following attestation bundles were made for triplets-0.1.0rc4-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.1.0rc4-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for triplets-0.1.0rc4-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 1c1c675cc8b8884d58a6020df4af0481962a92c6758e3c6a4243a3183f86d687
MD5 7250005dc3edc64bdf8c62431a6d1cb0
BLAKE2b-256 9fdd3b7e658f0ff7153078d23331bc37b1ac516a5b098ceee394ae1e3499f7c9

See more details on using hashes here.

Provenance

The following attestation bundles were made for triplets-0.1.0rc4-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.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.1.0rc4-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for triplets-0.1.0rc4-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7466f3a0107ec06c2398bd9180a099f1ac16b2d83a028d986ce784d0997c3766
MD5 b8431b813ad41100229a16a96d2095f2
BLAKE2b-256 7ddb970a54d56099c57404e832f4bf6906157bd8e750b068d3c4b530b63bb4f4

See more details on using hashes here.

Provenance

The following attestation bundles were made for triplets-0.1.0rc4-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.1.0rc4-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for triplets-0.1.0rc4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 b75a6b4b3fb78d9d8e73637adad2540b629a6b0db24b45f8a05a50f75d5c3afd
MD5 3fe35c59d4de9bf3ad5ab9e6b1f7e881
BLAKE2b-256 f3baf77df6087c26a0bb0e5cb58d6f56065a4178af311a52059ceb188bdc3a89

See more details on using hashes here.

Provenance

The following attestation bundles were made for triplets-0.1.0rc4-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.1.0rc4-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for triplets-0.1.0rc4-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 58f2d1ca377ef5daa25e54796f2781cbd7812210300bd5d337be660412d4aaf9
MD5 4391bc4da439c501f3b1c420f5f015cb
BLAKE2b-256 dc6c1bef3b58192c352c6ceeb59cbb73487b30b8e469ba9516b32711fba458b3

See more details on using hashes here.

Provenance

The following attestation bundles were made for triplets-0.1.0rc4-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.1.0rc4-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for triplets-0.1.0rc4-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 88398adc0b7807c4aadb5a22d95ac9e5efa95caa99c97bf4cfc5f4c68f0e44db
MD5 72998ed7463c5bd228b81f93dd889cae
BLAKE2b-256 37a411583f521ed160d8a6cc93023de0011e4902da933c4498368415c7e8b155

See more details on using hashes here.

Provenance

The following attestation bundles were made for triplets-0.1.0rc4-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.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.1.0rc4-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for triplets-0.1.0rc4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9c3a8b12f79be04848ff5c803a4557a87d3cd0a9f8e9eb195ac38ef6fc805377
MD5 c60ede7802754ea9cc007f132a637fae
BLAKE2b-256 696c561f524d0ccbf0e5cb55caaa11f43ff33256fe07a07ce83c1c96620267e8

See more details on using hashes here.

Provenance

The following attestation bundles were made for triplets-0.1.0rc4-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.1.0rc4-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for triplets-0.1.0rc4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 9a9a7c3dc4fd9f159f8d6c04c5cef67ca626a5f81459319280b9dac184fc687b
MD5 16ca58e40511292e19d8ba00d73f5c3d
BLAKE2b-256 e823f02a2c202689b6aec0372c656b8c6ce97e876ac5bbeddff2239f64575173

See more details on using hashes here.

Provenance

The following attestation bundles were made for triplets-0.1.0rc4-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.1.0rc4-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for triplets-0.1.0rc4-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d927aac022f23fb2d4715f4fdee30b5c6f7e6fbde7f91b02927475ac8d966f75
MD5 b850a3963c55b2de79e86b0b141b2f28
BLAKE2b-256 332e9c4af784083bb103c7a0082bd1a1f66e62a810acb139206d5661433e79a5

See more details on using hashes here.

Provenance

The following attestation bundles were made for triplets-0.1.0rc4-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.1.0rc4-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for triplets-0.1.0rc4-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 be7b7093665a7602a64c6a0ac3cb2addf97a63b8ea1d21f3755d92af0945a2a4
MD5 4c4b8d337ce630eae0745c953277fb8a
BLAKE2b-256 af59fb0b04436f42e524758077ab718779ba5dad28575a9f762f27c1b0af612e

See more details on using hashes here.

Provenance

The following attestation bundles were made for triplets-0.1.0rc4-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.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.1.0rc4-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for triplets-0.1.0rc4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6642d7a160c493b8631cb8124d8b6eb3151e119944254816df9cd92b20c9c316
MD5 aac3f09bb9f35259f3fecd83b3ab7511
BLAKE2b-256 817af256c83b9331f02b1de0c7495986947ab1491f18a99dccc7a11823570016

See more details on using hashes here.

Provenance

The following attestation bundles were made for triplets-0.1.0rc4-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.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page