Skip to main content

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.

Project description

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.

Usage

Import and instantiate the moduel

from 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", type="text")
print(d)

Why another package/module?

Inspired by the R based eurlex package, which helped a lot with the SPARQL construction and understanding and general inspiration. There is also https://github.com/seljaseppala/eu_corpus_compiler but that also only does regulatory/legislative documents. 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. Thus, this package was born.

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

pyeurlex-0.1.8.tar.gz (23.5 kB view details)

Uploaded Source

Built Distribution

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

pyeurlex-0.1.8-py3-none-any.whl (23.0 kB view details)

Uploaded Python 3

File details

Details for the file pyeurlex-0.1.8.tar.gz.

File metadata

  • Download URL: pyeurlex-0.1.8.tar.gz
  • Upload date:
  • Size: 23.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.15 CPython/3.10.6 Darwin/19.6.0

File hashes

Hashes for pyeurlex-0.1.8.tar.gz
Algorithm Hash digest
SHA256 738e0ce5c1a91e70ee44b0bf523fdca10fcd80fe80e82c67c8ce1e0ab23bb058
MD5 9ba3d926ba6f3dce6209ee2af3f797e2
BLAKE2b-256 0ab36eabb0aa7ef47cf94f3153614c327c8f8e27fe2fdb210f6f5948b1d13e3e

See more details on using hashes here.

File details

Details for the file pyeurlex-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: pyeurlex-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 23.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.15 CPython/3.10.6 Darwin/19.6.0

File hashes

Hashes for pyeurlex-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 ead6d7e3b050a376aea8e9383d67f96376d207ae69e2d78e5c9273b067354ebf
MD5 2ed6d5329f3455b7560a903f5b4fc1a5
BLAKE2b-256 5bb8c37d889ad34d8005be599d60a743df34c7373b9a37a8950d035520cb50ab

See more details on using hashes here.

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