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.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()

Accessor namespace

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

data.triplets.tableview_by_type("ACLineSegment")
data.triplets.get_types_count()
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
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.

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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

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

File metadata

  • Download URL: triplets-0.1.0rc5.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.0rc5.tar.gz
Algorithm Hash digest
SHA256 52b73fc082af02d7051a68d76e89c35fec73c9f600db00f60acdd85293ec8fb9
MD5 4228b6fb5c22026b6678b9d1492e4dd7
BLAKE2b-256 12c53902a66f9e8ff7e905fdfeeb9b44f4f0c6bf1e17361e8554794f2968039c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for triplets-0.1.0rc5-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 36f0352f94db57dc016d0af48dfb5f781cfb390dc398332c70c267f97110820d
MD5 3802b874ff3bf31addbeaf9bfa2fe2f9
BLAKE2b-256 dabbe7d8d60068ddae94a3b6eb14fe9ccf7b58e10a1fcc5865aee2ab386185b8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for triplets-0.1.0rc5-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6e6e5c9f181578aa782f94aab201010cd4d856af8c5576dd15a73f42f522f3f0
MD5 8458005be71099814127620a12d8e8de
BLAKE2b-256 351c5e0e2ccc2c882492cb37c611762ceeb4746fc4f465da9426b363eb7dfb43

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for triplets-0.1.0rc5-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 70df3de8597eee7ea7a41ea574f4f719698534985c8215e28db7cfa5bb25a759
MD5 15f22b61c4a009dd75d73e5dd18df1c6
BLAKE2b-256 72201d21708849dde91adcd9a6476d354776d32c127f70bf4865972bfbacea09

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for triplets-0.1.0rc5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 39f08313226bcad80937d98855d994c99a2c8b1aaa85482b07a47724644bce12
MD5 b52af58ae54bce721f19166f129c533f
BLAKE2b-256 fec76bf72cb87c61ffc8f79cd466394725bf362b28deced353484f831b96848c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for triplets-0.1.0rc5-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b10d2ba20c1629cce96f60e773b56365af326e2cde42aea93aaa3d7a4afd4924
MD5 087a4586dccd08e778917b4234f573c1
BLAKE2b-256 559bc91ad705da0bb7f0adccd2d3ac0ad668650f8ce9d53942b0eca5e0a349a0

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for triplets-0.1.0rc5-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b20895073195d36f4b46276b79b3647ab7182d3d042a5dee173fb362de377dff
MD5 ab4847f3489ec0f1c10060d66bc1d92a
BLAKE2b-256 e9e48299293f66b2c05292182758b31276a8cccca5693278fb9a0e57aa970ba2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for triplets-0.1.0rc5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 60944be84ad4ed98f003f91272a21dad1e91c8065f344c0ffc0eaaeafe90c423
MD5 956290d1449614ceb0a2b336b9af01db
BLAKE2b-256 b5f63f5eada06b26c71e287b2ce12a4bdc9dbada68d2ec87f9310fbf70772a75

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for triplets-0.1.0rc5-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3092df217415c88d6ff6a3df3955507ffde92fb8ef589e3106435c7bfe9a9f4a
MD5 b91be52613c5e032dca8c358d00fd97f
BLAKE2b-256 404486ea08495f221a1b1cbbc99e3032ef6d3a39d326612c7b581940dd924bb8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for triplets-0.1.0rc5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 258a91687d37e538848bc324419891b576d8632bbf964e5d6841a3ef45102b02
MD5 b63df9c37166fb691375ce36ae3f0365
BLAKE2b-256 fe76e149ac2cbf095d15984b166735e1a55fd81a87b289aa29d16e77c3829d9a

See more details on using hashes here.

Provenance

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