A SDMX in RDF Turtle 1.1 format parser to generate valid JSON-LD and send to FIWARE Context Brokers using ETSI NGSI-LD.
Project description
SDMX to JSON-LD Parser
SDMX (Turtle) to NGSI-LD (JSON-LD) converter
A SDMX to JSON-LD parser to communicate with FIWARE Context Brokers using ETSI NGSI-LD.
Explore the docs »
View Demo
·
Report Bug
·
Request Feature
About The Project
A SDMX in RDF Turtle 1.1 format parser to generate valid JSON-LD and send to FIWARE Context Brokers using ETSI NGSI-LD.
It is based on a EBNF LALR(1) grammar.
This project is part of INTERSTAT. For more information about the INTERSTAT Project, please check the url https://cef-interstat.eu.
Dependencies
The dependencies of the sdmx2jsonld python package are the following:
- Lark - a modern general-purpose parsing library for Python.
- hi-dateinfer - a python library to infer date format from examples.
- Loguru - a library which aims to bring enjoyable logging in Python.
- Requests - an elegant and simple HTTP library for Python, built for human beings.
- RDFLib - a pure Python package for working with RDF.
For more details about the versions of each library, please refer to requirements.txt.
Installing SDMX2JSON-LD and Supported Versions
SDMX2JSON-LD is available on PyPI:
$ python -m pip install sdmx2jsonld
SDMX2JSON-LD officially supports Python 3.10+.
Usage
To execute the python module you can follow the following code to parse the RDF Turtle file to generate the JSON-LD content to be sent to the FIWARE Context Broker:
from sdmx2jsonld.transform.parser import Parser
from sdmx2jsonld.exceptions import UnexpectedEOF, UnexpectedInput, UnexpectedToken
file_in = open("structures-accounts.ttl")
generate_files = True
# Start parsing the file
my_parser = Parser()
try:
my_parser.parsing(content=file_in, out=generate_files)
except UnexpectedToken as e:
print(e)
except UnexpectedInput as e:
print(e)
except UnexpectedEOF as e:
print(e)
Where:
file_in
is the RDF Turtle content that can be a string in StringIO class or a read file in TextIOWrapper class.file_out
is a boolean variable to indicate if we want to save the JSON-LD parser content into files (True) or we want to show the content in the screen (False).
Contributing
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated. If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Contact
Fernando López - @flopezaguilar - fernando.lopez@fiware.org
Project Link: https://github.com/flopezag/IoTAgent-Turtle
License
Distributed under the Apache2.0 License. See LICENSE for more information.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file sdmx2json_ld-1.0.0.tar.gz
.
File metadata
- Download URL: sdmx2json_ld-1.0.0.tar.gz
- Upload date:
- Size: 39.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.10.6 Linux/6.2.0-10014-tuxedo
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1154f3db71293b2d875a8d0e914c9df9609ff3d3d0e4617010a02107bec40677 |
|
MD5 | f3937cb0cfed21249bf6621f09a2fcd8 |
|
BLAKE2b-256 | 2b22fe4e295f3e5c66acddc66dd7519fd1472b7c3c29a6dbf3e83f333da7d858 |
File details
Details for the file sdmx2json_ld-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: sdmx2json_ld-1.0.0-py3-none-any.whl
- Upload date:
- Size: 89.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.10.6 Linux/6.2.0-10014-tuxedo
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d3be8d49109a64845466e5452057c561152c6dfbf512405d64a42b746e71eae |
|
MD5 | caad2fe5b43496b0b10364fb2f09a90b |
|
BLAKE2b-256 | 8560db16d97fdd7f051169ad75fe1e3fcd313890443cf9fd4ae53a2a1899eff5 |