Skip to main content

Fast RPSL parser with Polars DataFrame output

Project description

polars-rpsl

Fast RPSL (Routing Policy Specification Language) parser with Polars DataFrame output.

Installation

pip install polars-rpsl

Quickstart with uv

$ uv run --with polars-rpsl,smart_open[http] python
Installed 11 packages in 7ms
Python 3.12.11 (main, Aug  8 2025, 17:06:48) [Clang 20.1.4 ] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from polars_rpsl import read_rpsl
>>> from smart_open import open
>>> with open('https://ftp.ripe.net/ripe/dbase/split/ripe.db.aut-num.gz', 'rb') as f:
...     df = read_rpsl(f)
...
>>> df
shape: (39_016, 1)
┌─────────────────────────────────┐
│ attributes                      │
│ ---                             │
│ list[struct[2]]                 │
╞═════════════════════════════════╡
│ [{"aut-num","AS3255"}, {"as-na… │
│ [{"aut-num","AS6837"}, {"as-na… │
│ [{"aut-num","AS15756"}, {"as-n… │
│ [{"aut-num","AS16054"}, {"org"… │
│ [{"aut-num","AS9205"}, {"as-na… │
│                                │
│ [{"aut-num","AS203790"}, {"as-… │
│ [{"aut-num","AS203786"}, {"as-… │
│ [{"aut-num","AS203771"}, {"as-… │
│ [{"aut-num","AS203766"}, {"as-… │
│ [{"aut-num","AS203757"}, {"as-… │
└─────────────────────────────────┘

Usage

Schema-less reading

Read RPSL data into a nested structure where each object is a list of attribute name/value pairs:

from polars_rpsl import read_rpsl

df = read_rpsl("ripe.db.route.gz")
print(df)

Output:

shape: (3, 1)
┌─────────────────────────────────────────────────┐
│ attributes                                      │
│ ---                                             │
│ list[struct[2]]                                 │
╞═════════════════════════════════════════════════╡
│ [{"route","192.0.2.0/24"}, {"origin","AS65000"}│
│ , {"mnt-by","MAINT-AS65000"}]                   │
│ [{"route","198.51.100.0/24"}, {"origin","AS650…│
│ [{"route","203.0.113.0/24"}, {"origin","AS6500…│
└─────────────────────────────────────────────────┘

Schema-based reading

Read RPSL data into a flat DataFrame with typed columns:

import polars as pl
from polars_rpsl import read_rpsl

schema = pl.Schema({
    "route": pl.String,
    "origin": pl.String,
    "mnt-by": pl.List(pl.String),  # Multi-valued attribute
})

df = read_rpsl("ripe.db.route.gz", schema=schema)
print(df)

Output:

shape: (3, 3)
┌─────────────────┬──────────┬──────────────────────────────┐
│ route           ┆ origin   ┆ mnt-by                       │
│ ---             ┆ ---      ┆ ---                          │
│ str             ┆ str      ┆ list[str]                    │
╞═════════════════╪══════════╪══════════════════════════════╡
│ 192.0.2.0/24    ┆ AS65000  ┆ ["MAINT-AS65000"]            │
│ 198.51.100.0/24 ┆ AS65001  ┆ ["MAINT-AS65001", "RIPE-NCC… │
│ 203.0.113.0/24  ┆ AS65002  ┆ ["MAINT-AS65002"]            │
└─────────────────┴──────────┴──────────────────────────────┘

Schema-based reading:

  • Supports pl.String for single-valued attributes
  • Supports pl.List(pl.String) for multi-valued attributes
  • Returns None for missing single-valued attributes
  • Returns empty list [] for missing multi-valued attributes
  • Raises an error if a single-valued attribute appears multiple times
  • Ignores attributes not defined in the schema

Reading gzip files

Gzip-compressed files (.gz) are automatically detected and decompressed:

df = read_rpsl("ripe.db.route.gz")

Development

# Install dependencies
uv sync

# Build and install in development mode
uv run maturin develop

# Run tests
uv run pytest tests/ -v

# Build wheel
uv run maturin build --release --out dist/

Project Structure

rpsl-reader/
├── crates/
│   ├── rpsl-parser/     # Core parser (minimal dependencies)
│   └── polars-rpsl/     # Polars + Python bindings
├── python/
│   └── polars_rpsl/     # Python wrapper
└── tests/               # Python tests

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

polars_rpsl-0.1.4-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.8 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

polars_rpsl-0.1.4-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.8 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

polars_rpsl-0.1.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.8 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

polars_rpsl-0.1.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.8 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

polars_rpsl-0.1.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

polars_rpsl-0.1.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

polars_rpsl-0.1.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.8 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

File details

Details for the file polars_rpsl-0.1.4-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for polars_rpsl-0.1.4-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a8e40bfe46c51a6b3c8d488595befc992b63551fa7b86ca3598c31eeb98cd7cd
MD5 f3a533e60b9fb8ff9253d205061c33ff
BLAKE2b-256 30e52bf528dc7a361e9ee73489213bd41e8f20372193fddb46db909d5187aa1b

See more details on using hashes here.

Provenance

The following attestation bundles were made for polars_rpsl-0.1.4-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: python.yaml on ragnard/rpsl-reader

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file polars_rpsl-0.1.4-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for polars_rpsl-0.1.4-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ff06c8285b2b55eb824b77a6111d2f935623b1a868254508e11c121bf63a2fd7
MD5 4545effe0b3646df209213c8990478ee
BLAKE2b-256 c21d5a2f28e7c8414039e3fdbab74b2446c57d1a5956f9ba04d5d265e1ff6eb1

See more details on using hashes here.

Provenance

The following attestation bundles were made for polars_rpsl-0.1.4-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: python.yaml on ragnard/rpsl-reader

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file polars_rpsl-0.1.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for polars_rpsl-0.1.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a2b88987a3e08a43bb9a78cee86b362e6774055931f55bf02816b42eb935fb0f
MD5 373e42e256bc4d4a646a085af12a4ad7
BLAKE2b-256 fa5952b0f935167fc21b64dcd5aca4f317978eeeb808153e50f3537a5fb9b322

See more details on using hashes here.

Provenance

The following attestation bundles were made for polars_rpsl-0.1.4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: python.yaml on ragnard/rpsl-reader

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file polars_rpsl-0.1.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for polars_rpsl-0.1.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cd9b04e8204718360467d6610f1714d542bd120aa7751cc65a73638158ede1b4
MD5 76696b949be6f18b7d7a02301168d08f
BLAKE2b-256 974176319addb196e98a2f4db389f6f96603d85dae813a3a9b46a30e4060a85d

See more details on using hashes here.

Provenance

The following attestation bundles were made for polars_rpsl-0.1.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: python.yaml on ragnard/rpsl-reader

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file polars_rpsl-0.1.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for polars_rpsl-0.1.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4cb60ead5d9b7390170f3c2d417ade6cb187ea1f14d447e5783d53eec480113f
MD5 d7e7de910176d5e9da7d5039b5b26e99
BLAKE2b-256 08dbeba256e11e93054b40dc6701e36bc84abf8074b86880374df900674037db

See more details on using hashes here.

Provenance

The following attestation bundles were made for polars_rpsl-0.1.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: python.yaml on ragnard/rpsl-reader

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file polars_rpsl-0.1.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for polars_rpsl-0.1.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 beea93b6de09b83000e14a3a63255248d7cd10474123ea73e82735efb40d7b86
MD5 380a2825a49ed3d350fb0457f8b73b87
BLAKE2b-256 9f247cb55419cae405bc4d2bb5b9415c75797ea2e8ade1a96a8142d2ef0c23fd

See more details on using hashes here.

Provenance

The following attestation bundles were made for polars_rpsl-0.1.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: python.yaml on ragnard/rpsl-reader

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file polars_rpsl-0.1.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for polars_rpsl-0.1.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e0c82c64cd8aadc93f01e5bfc61802a78992d6a89686abcfe727af66eda79c24
MD5 67ff3bf3029785e57f6d3af5f8aff7d5
BLAKE2b-256 16c005e31178261d8fb5632220c3eda36efb7a2f128f1f6e9fccd27d94d30849

See more details on using hashes here.

Provenance

The following attestation bundles were made for polars_rpsl-0.1.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: python.yaml on ragnard/rpsl-reader

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