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_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_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.0rc3.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.0rc3-cp313-cp313-win_amd64.whl (2.3 MB view details)

Uploaded CPython 3.13Windows x86-64

triplets-0.1.0rc3-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.0rc3-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.0rc3-cp313-cp313-macosx_11_0_arm64.whl (2.3 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

triplets-0.1.0rc3-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.0rc3-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.0rc3-cp312-cp312-macosx_11_0_arm64.whl (2.3 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

triplets-0.1.0rc3-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.0rc3-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.0rc3-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.0rc3.tar.gz.

File metadata

  • Download URL: triplets-0.1.0rc3.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.0rc3.tar.gz
Algorithm Hash digest
SHA256 d05b8a32657ed12ffb63bf38d42a4a000dc8e58cb6afc95ba495c32abc54e9f5
MD5 55ffa9b4d96ddb5f7a306a6296c2d0d0
BLAKE2b-256 2544053eb36ad8a5e46d9aae038f19cd6ed47f4045a743467b28caa9eb02e99f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for triplets-0.1.0rc3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 0921559dfe2730b06bd61854b7fb559cd2300004406247f540b1a79065476886
MD5 e6dd3e34b72e72779c0f8b7460f66c16
BLAKE2b-256 1e22fd9e3d5f7f439edf9207e82a40a024e79d1d8530cbeb43f4d052785dd8d6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for triplets-0.1.0rc3-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2101f30ae96c9e2dafc1740f7f64ebf220f6ad2718c003990415a5e7e0f4e0f1
MD5 cd2482b5997ddf0b50586dd6caaaf14b
BLAKE2b-256 3774d8d4849a72d426608448135a576273ba2942f01dc85507ed424030c7c42d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for triplets-0.1.0rc3-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 7346c19942a4645719e93b458eb50cae1f0687c0a2501b51d6a66c38006e8f02
MD5 bedad7079528fdaa08af34af792ebeed
BLAKE2b-256 ece4866873502272c6bc1f1f27f336d75b4747ac3920d958a3b657f9cfd82e23

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for triplets-0.1.0rc3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 41ae61710e52dcc917a946fb2ac7427eb2beede1a5a64209f4ad2cecc3da6844
MD5 119a0f77a6ad9368434d619c6293bf3a
BLAKE2b-256 16ae05eba0a21820f1534bbdfc264e9b4405d3e59781e33850d369a0ebc0e008

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for triplets-0.1.0rc3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 0c592133f7e5485929f58cc2dd78a852fd5f28a02a4cc8d3e76b10ac5aefd084
MD5 be733b84f902271d642a0278262a3256
BLAKE2b-256 63f315642683e74784cbed4ad2dabb6226179d3bab5b13194960efa5fc2a5983

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for triplets-0.1.0rc3-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 815e8c66d80d62a9e7d5a0919aa310822cd23a0cfd741820aca75acc430224ca
MD5 6bbb1da0de2b375f6692dfd9096e1329
BLAKE2b-256 12131f7b3b46a607c203420759d29c05d624d8fe655da495c744609b1c40bd1f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for triplets-0.1.0rc3-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 2506233e1224a0045d57181ce207b76cda71fb9bfc886fe292c7fbbe67e93740
MD5 19c9ffc3ebe4c6e7eaa3ab9a301a94eb
BLAKE2b-256 7b4261fd84fc32b52932a8c01b2b483d74af1beba299dc50bba53594ec1f2909

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for triplets-0.1.0rc3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0ba101ec46ddb0fde168b8cc247cb56076f97126baf4c498e6182529a5604c86
MD5 d62df603e3c8c10b0d2741e55b2a04e5
BLAKE2b-256 310f7db742584e4acc4e8d26d0563bdef7fce10ac0c6f9d275e64ed5442085ad

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for triplets-0.1.0rc3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 372bf7aab970035dde5be5db59a137660937e1a5e3e3e6ca12b58b534a08f208
MD5 5e375bc5750770c8668b2243c0bbe4a7
BLAKE2b-256 809a15b233079a396e143d200f006b77cff389f4a302897fb3ad2f35a6ae0386

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for triplets-0.1.0rc3-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 95a8b506a095132dfe805ac936987124585f2c48ad98f85c4d009592cdfeea9f
MD5 e0bee6ce477a6949ff5f430d3ffea8ab
BLAKE2b-256 40a039d00cf709b4af55c93c2f9bf2768ade67d171c58d13eb7181d786b2d2ec

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for triplets-0.1.0rc3-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 a7fe73c10bea0e757af0d5100c973ce617e54915c0902ef577cf6a5031e74056
MD5 528ed4121f21652a42a1f9fdf80c691b
BLAKE2b-256 88de86bd0ff8460eed6c2580c7dc0a8a4640b93cda1070e66ce641c938fedccf

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for triplets-0.1.0rc3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 39fb9f18ef1ef60233a6c060758118d9b071bc93ecb1e82b18665385e6578b0a
MD5 d7075ca0324c4705a20d2e957198fdd4
BLAKE2b-256 8599fdb39f3e28aebc8a1d291c86e52fae5fe517299046f10f2142b124a20959

See more details on using hashes here.

Provenance

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