sdmx2json-ld


Namesdmx2json-ld JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://github.com/flopezag/IoTAgent-Turtle
SummaryA SDMX in RDF Turtle 1.1 format parser to generate valid JSON-LD and send to FIWARE Context Brokers using ETSI NGSI-LD.
upload_time2023-07-25 10:37:03
maintainer
docs_urlNone
authorFernando López
requires_python>=3.8,<4.0
license
keywords parsing etsi ngsi-ld sdmx
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <div id="top"></div>

# SDMX to JSON-LD Parser

<!-- PROJECT SHIELDS -->
[![Stable Version][version-shield]][version-url]
[![Issues][issues-shield]][issues-url]
[![Apache2.0 License][license-shield]][license-url]
[![Python Versions][python-shield]][python-url]
[![Package Status][package-shield]][package-url]
[![LinkedIn][linkedin-shield]][linkedin-url]


<!-- PROJECT LOGO -->
<br />
<div align="center">
  <a href="https://github.com/flopezag/IoTAgent-Turtle">
    <img src="https://raw.githubusercontent.com/flopezag/IoTAgent-Turtle/master/images/logo.png" 
alt="Logo" width="280" height="160">
  </a>

<h3 align="center">SDMX (Turtle) to NGSI-LD (JSON-LD) converter</h3>

  <p align="center">
    A SDMX to JSON-LD parser to communicate with FIWARE Context Brokers using ETSI NGSI-LD.
    <br />
    <a href="https://github.com/flopezag/IoTAgent-Turtle"><strong>Explore the docs »</strong></a>
    <br />
    <br />
    <a href="https://github.com/flopezag/IoTAgent-Turtle">View Demo</a>
    ·
    <a href="https://github.com/flopezag/IoTAgent-Turtle/issues">Report Bug</a>
    ·
    <a href="https://github.com/flopezag/IoTAgent-Turtle/issues">Request Feature</a>
  </p>
</div>


<!-- ABOUT THE PROJECT -->
## 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](https://github.com/flopezag/IoTAgent-Turtle/blob/master/sdmx2jsonld/grammar/grammar.lark).

This project is part of INTERSTAT. For more information about the INTERSTAT Project, please check the url 
https://cef-interstat.eu.


<p align="right">(<a href="#top">back to top</a>)</p>


### Dependencies

The dependencies of the sdmx2jsonld python package are the following:

* [Lark - a modern general-purpose parsing library for Python](https://lark-parser.readthedocs.io/en/latest).
* [hi-dateinfer - a python library to infer date format from examples](https://github.com/hi-primus/hi-dateinfer).
* [Loguru - a library which aims to bring enjoyable logging in Python](https://loguru.readthedocs.io/en/stable/index.html).
* [Requests - an elegant and simple HTTP library for Python, built for human beings](https://requests.readthedocs.io).
* [RDFLib - a pure Python package for working with RDF](https://rdflib.readthedocs.io).

For more details about the versions of each library, please refer to 
[requirements.txt](https://github.com/flopezag/IoTAgent-Turtle/blob/master/requirements.txt).

<p align="right">(<a href="#top">back to top</a>)</p>



<!-- GETTING STARTED -->
## Installing SDMX2JSON-LD and Supported Versions
SDMX2JSON-LD is available on PyPI:

```bash
$ python -m pip install sdmx2jsonld
```

SDMX2JSON-LD officially supports Python 3.10+.

<p align="right">(<a href="#top">back to top</a>)</p>



<!-- USAGE EXAMPLES -->
## 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:

```python
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).

<p align="right">(<a href="#top">back to top</a>)</p>


<!-- CONTRIBUTING -->
## 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!

1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the Branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request

<p align="right">(<a href="#top">back to top</a>)</p>


<!-- CONTACT -->
## Contact

Fernando López - [@flopezaguilar](https://twitter.com/flopezaguilar) - fernando.lopez@fiware.org

Project Link: [https://github.com/flopezag/IoTAgent-Turtle](https://github.com/flopezag/IoTAgent-Turtle)

<p align="right">(<a href="#top">back to top</a>)</p>


<!-- LICENSE -->
## License

Distributed under the Apache2.0 License. See [LICENSE](https://github.com/flopezag/IoTAgent-Turtle/blob/master/LICENSE) 
for more information.

<p align="right">(<a href="#top">back to top</a>)</p>


<!-- MARKDOWN LINKS & IMAGES -->
<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
[issues-shield]: https://img.shields.io/github/issues/flopezag/IoTAgent-Turtle.svg?style=flat
[issues-url]: https://github.com/flopezag/IoTAgent-Turtle/issues

[license-shield]: https://img.shields.io/github/license/flopezag/IoTAgent-Turtle
[license-url]: https://github.com/flopezag/IoTAgent-Turtle/blob/master/LICENSE

[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=flat&logo=linkedin&colorB=555
[linkedin-url]: https://linkedin.com/in/fernandolopezaguilar

[python-shield]: https://img.shields.io/pypi/pyversions/sdmx2json-ld
[python-url]: https://pypi.org/project/sdmx2json-ld

[version-shield]: https://img.shields.io/pypi/v/sdmx2json-ld
[version-url]: https://pypi.org/project/sdmx2json-ld/#history

[package-shield]: https://img.shields.io/pypi/status/sdmx2json-ld
[package-url]: https://pypi.org/project/sdmx2json-ld

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/flopezag/IoTAgent-Turtle",
    "name": "sdmx2json-ld",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "",
    "keywords": "parsing,ETSI NGSI-LD,SDMX",
    "author": "Fernando L\u00f3pez",
    "author_email": "fernando.lopez@fiware.org",
    "download_url": "https://files.pythonhosted.org/packages/2b/22/fe4e295f3e5c66acddc66dd7519fd1472b7c3c29a6dbf3e83f333da7d858/sdmx2json_ld-1.0.0.tar.gz",
    "platform": null,
    "description": "<div id=\"top\"></div>\n\n# SDMX to JSON-LD Parser\n\n<!-- PROJECT SHIELDS -->\n[![Stable Version][version-shield]][version-url]\n[![Issues][issues-shield]][issues-url]\n[![Apache2.0 License][license-shield]][license-url]\n[![Python Versions][python-shield]][python-url]\n[![Package Status][package-shield]][package-url]\n[![LinkedIn][linkedin-shield]][linkedin-url]\n\n\n<!-- PROJECT LOGO -->\n<br />\n<div align=\"center\">\n  <a href=\"https://github.com/flopezag/IoTAgent-Turtle\">\n    <img src=\"https://raw.githubusercontent.com/flopezag/IoTAgent-Turtle/master/images/logo.png\" \nalt=\"Logo\" width=\"280\" height=\"160\">\n  </a>\n\n<h3 align=\"center\">SDMX (Turtle) to NGSI-LD (JSON-LD) converter</h3>\n\n  <p align=\"center\">\n    A SDMX to JSON-LD parser to communicate with FIWARE Context Brokers using ETSI NGSI-LD.\n    <br />\n    <a href=\"https://github.com/flopezag/IoTAgent-Turtle\"><strong>Explore the docs \u00bb</strong></a>\n    <br />\n    <br />\n    <a href=\"https://github.com/flopezag/IoTAgent-Turtle\">View Demo</a>\n    \u00b7\n    <a href=\"https://github.com/flopezag/IoTAgent-Turtle/issues\">Report Bug</a>\n    \u00b7\n    <a href=\"https://github.com/flopezag/IoTAgent-Turtle/issues\">Request Feature</a>\n  </p>\n</div>\n\n\n<!-- ABOUT THE PROJECT -->\n## About The Project\n\nA SDMX in RDF Turtle 1.1 format parser to generate valid JSON-LD and send to FIWARE Context Brokers using ETSI NGSI-LD.\n\nIt is based on a \n[EBNF LALR(1) grammar](https://github.com/flopezag/IoTAgent-Turtle/blob/master/sdmx2jsonld/grammar/grammar.lark).\n\nThis project is part of INTERSTAT. For more information about the INTERSTAT Project, please check the url \nhttps://cef-interstat.eu.\n\n\n<p align=\"right\">(<a href=\"#top\">back to top</a>)</p>\n\n\n### Dependencies\n\nThe dependencies of the sdmx2jsonld python package are the following:\n\n* [Lark - a modern general-purpose parsing library for Python](https://lark-parser.readthedocs.io/en/latest).\n* [hi-dateinfer - a python library to infer date format from examples](https://github.com/hi-primus/hi-dateinfer).\n* [Loguru - a library which aims to bring enjoyable logging in Python](https://loguru.readthedocs.io/en/stable/index.html).\n* [Requests - an elegant and simple HTTP library for Python, built for human beings](https://requests.readthedocs.io).\n* [RDFLib - a pure Python package for working with RDF](https://rdflib.readthedocs.io).\n\nFor more details about the versions of each library, please refer to \n[requirements.txt](https://github.com/flopezag/IoTAgent-Turtle/blob/master/requirements.txt).\n\n<p align=\"right\">(<a href=\"#top\">back to top</a>)</p>\n\n\n\n<!-- GETTING STARTED -->\n## Installing SDMX2JSON-LD and Supported Versions\nSDMX2JSON-LD is available on PyPI:\n\n```bash\n$ python -m pip install sdmx2jsonld\n```\n\nSDMX2JSON-LD officially supports Python 3.10+.\n\n<p align=\"right\">(<a href=\"#top\">back to top</a>)</p>\n\n\n\n<!-- USAGE EXAMPLES -->\n## Usage\n\nTo execute the python module you can follow the following code to parse the RDF Turtle file to generate the JSON-LD \ncontent to be sent to the FIWARE Context Broker:\n\n```python\nfrom sdmx2jsonld.transform.parser import Parser\nfrom sdmx2jsonld.exceptions import UnexpectedEOF, UnexpectedInput, UnexpectedToken\n\nfile_in = open(\"structures-accounts.ttl\")\ngenerate_files = True\n\n# Start parsing the file\nmy_parser = Parser()\n\ntry:\n    my_parser.parsing(content=file_in, out=generate_files)\nexcept UnexpectedToken as e:\n    print(e)\nexcept UnexpectedInput as e:\n    print(e)\nexcept UnexpectedEOF as e:\n    print(e)\n```\n\nWhere:\n* `file_in` is the RDF Turtle content that can be a string in StringIO class or a read file in TextIOWrapper class.\n* `file_out` is a boolean variable to indicate if we want to save the JSON-LD parser content into files (True) or we \nwant to show the content in the screen (False).\n\n<p align=\"right\">(<a href=\"#top\">back to top</a>)</p>\n\n\n<!-- CONTRIBUTING -->\n## Contributing\n\nContributions are what make the open source community such an amazing place to learn, inspire, and create. \nAny contributions you make are **greatly appreciated**. If you have a suggestion that would make this better, \nplease fork the repo and create a pull request. You can also simply open an issue with the tag \"enhancement\".\nDon't forget to give the project a star! Thanks again!\n\n1. Fork the Project\n2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the Branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\n<p align=\"right\">(<a href=\"#top\">back to top</a>)</p>\n\n\n<!-- CONTACT -->\n## Contact\n\nFernando L\u00f3pez - [@flopezaguilar](https://twitter.com/flopezaguilar) - fernando.lopez@fiware.org\n\nProject Link: [https://github.com/flopezag/IoTAgent-Turtle](https://github.com/flopezag/IoTAgent-Turtle)\n\n<p align=\"right\">(<a href=\"#top\">back to top</a>)</p>\n\n\n<!-- LICENSE -->\n## License\n\nDistributed under the Apache2.0 License. See [LICENSE](https://github.com/flopezag/IoTAgent-Turtle/blob/master/LICENSE) \nfor more information.\n\n<p align=\"right\">(<a href=\"#top\">back to top</a>)</p>\n\n\n<!-- MARKDOWN LINKS & IMAGES -->\n<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->\n[issues-shield]: https://img.shields.io/github/issues/flopezag/IoTAgent-Turtle.svg?style=flat\n[issues-url]: https://github.com/flopezag/IoTAgent-Turtle/issues\n\n[license-shield]: https://img.shields.io/github/license/flopezag/IoTAgent-Turtle\n[license-url]: https://github.com/flopezag/IoTAgent-Turtle/blob/master/LICENSE\n\n[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=flat&logo=linkedin&colorB=555\n[linkedin-url]: https://linkedin.com/in/fernandolopezaguilar\n\n[python-shield]: https://img.shields.io/pypi/pyversions/sdmx2json-ld\n[python-url]: https://pypi.org/project/sdmx2json-ld\n\n[version-shield]: https://img.shields.io/pypi/v/sdmx2json-ld\n[version-url]: https://pypi.org/project/sdmx2json-ld/#history\n\n[package-shield]: https://img.shields.io/pypi/status/sdmx2json-ld\n[package-url]: https://pypi.org/project/sdmx2json-ld\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A SDMX in RDF Turtle 1.1 format parser to generate valid JSON-LD and send to FIWARE Context Brokers using ETSI NGSI-LD.",
    "version": "1.0.0",
    "project_urls": {
        "Homepage": "https://github.com/flopezag/IoTAgent-Turtle",
        "Repository": "https://github.com/flopezag/IoTAgent-Turtle"
    },
    "split_keywords": [
        "parsing",
        "etsi ngsi-ld",
        "sdmx"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8560db16d97fdd7f051169ad75fe1e3fcd313890443cf9fd4ae53a2a1899eff5",
                "md5": "caad2fe5b43496b0b10364fb2f09a90b",
                "sha256": "1d3be8d49109a64845466e5452057c561152c6dfbf512405d64a42b746e71eae"
            },
            "downloads": -1,
            "filename": "sdmx2json_ld-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "caad2fe5b43496b0b10364fb2f09a90b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 89414,
            "upload_time": "2023-07-25T10:37:00",
            "upload_time_iso_8601": "2023-07-25T10:37:00.240356Z",
            "url": "https://files.pythonhosted.org/packages/85/60/db16d97fdd7f051169ad75fe1e3fcd313890443cf9fd4ae53a2a1899eff5/sdmx2json_ld-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2b22fe4e295f3e5c66acddc66dd7519fd1472b7c3c29a6dbf3e83f333da7d858",
                "md5": "f3937cb0cfed21249bf6621f09a2fcd8",
                "sha256": "1154f3db71293b2d875a8d0e914c9df9609ff3d3d0e4617010a02107bec40677"
            },
            "downloads": -1,
            "filename": "sdmx2json_ld-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "f3937cb0cfed21249bf6621f09a2fcd8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 39017,
            "upload_time": "2023-07-25T10:37:03",
            "upload_time_iso_8601": "2023-07-25T10:37:03.403750Z",
            "url": "https://files.pythonhosted.org/packages/2b/22/fe4e295f3e5c66acddc66dd7519fd1472b7c3c29a6dbf3e83f333da7d858/sdmx2json_ld-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-25 10:37:03",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "flopezag",
    "github_project": "IoTAgent-Turtle",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "sdmx2json-ld"
}
        
Elapsed time: 0.13061s