Skip to main content

pyeurlex package

This is a python module to create SPARQL queries for the EU Cellar repository, run them and subsequently download their data. Notably, it directly supports all resource types. Some parts like the SPARQL queries are based on the R-based eurlex package by Michal Ovadek, but then I wanted one for python and was not satisfied with existing python packages.

Status

Build and Test | codecov

Coverage Graph

Usage

Import and instantiate the moduel

from eurlex.eurlex import Eurlex
eur = Eurlex()

Then you can construct you query. (or alternatively you can use your own or one constructed via the wizard https://op.europa.eu/en/advanced-sparql-query-editor

q = eur.make_query(resource_type = "caselaw", order = True, limit = 10)
print(q)

Finally, you can run this query.

d = eur.query_eurlex(q)  # where q is a query generated in a previous step or a string defined by you
print(d)

This will return a pandas data frame of the results. Its columns depend on the the fields that you included. At the moment, not all fields are named properly in the dataframe and you will have to set their name manually if desired.

Once you pick a single url or identifier from the df, you can download a notice or data based on that indentifier. To download the notices as xml, use download_xml() as below.

x = eur.download_xml("32014R0001", notice="tree") # without the file parameter to specify the filename, the celex number will be used.
print(x)

To get data associated with an identifier, use get_data(). This will return the data as a string,

d = eur.get_data("http://publications.europa.eu/resource/celex/32016R0679", data_type="text")
print(d)

Why another package/module?

While there was already the R packages by Michal Ovadek, I wanted a python implementation. There is also https://github.com/seljaseppala/eu_corpus_compiler but that also only does regulatory/legislative documents. Additionally, there is https://pypi.org/project/eurlex/, but it for example does not have a way to generate SPARQL queries and is also very focused on legislation. In addition, while internally it uses SPARQL and cellar as well, its documentation is focused on accessing and processing documents via CELEX number, which is not really helpful to me. Another one is https://github.com/Lexparency/eurlex2lexparency which also seems to focus on legislative documents and

Metadata

Release files for pyeurlex 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyeurlex 0.3.0
File Size Uploaded Provenance
pyeurlex-0.3.0.tar.gz 24.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pyeurlex 0.3.0
File Interpreter ABI Platform
pyeurlex-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 50.0 kB

Release files / pyeurlex-0.3.0.tar.gz

Download URL pyeurlex-0.3.0.tar.gz
Size 24.9 kB
Tags Source
SHA-256 checksum
How to use checksums
d61e4c2463c4df8340597a660fd95cbcc69cf1b5ac00db7b2d221677b085f049
BLAKE2b-256 checksum
How to use checksums
8f4c84751a931ef7f6de04f47be083566f65f5354a6c4cffb5e330abde111410
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.2 CPython/3.10.19 Linux/6.14.0-1017-azure

Release files / pyeurlex-0.3.0-py3-none-any.whl

Download URL pyeurlex-0.3.0-py3-none-any.whl
Size 25.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
70119475e8f1b8f0531ce27f0e4c1720a8f59cd6b9b5aa1569b234a7ee1e7943
BLAKE2b-256 checksum
How to use checksums
60aeb43fecfb812eab4a25517837ff54327f6365128812185d54c717ffa6a4b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.2 CPython/3.10.19 Linux/6.14.0-1017-azure

Security for pyeurlex 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

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