No project description provided
Project description
OTLMOW-Converter
OTLMOW Project
This project aims to implement the Flemish data standard OTL (https://wegenenverkeer.data.vlaanderen.be/) in Python. It is split into different packages to reduce compatibility issues
- otlmow_model
- otlmow_modelbuilder
- otlmow_converter (you are currently looking at this package)
- otlmow_template
- otlmow_postenmapping
- otlmow_davie
- otlmow_visuals
- otlmow_gui
Functionality
The core functionality of this library is creating instances of otlmow_model classes by converting or creating them. The instances can then be manipulated and finally exported to a different format. When exporting to a file, a DAVIE compliant format can be chosen so that the data can be imported in the DAVIE application.
Supported formats and objects
Using this library, you can convert between the following objects and formats
- otlmow class objects
- class objects can simply be instantiated in code or created using the helpers in the otlmow-model library
- files
- chose one of the many supported file formats to read from or write data to
- some file formats are DAVIE compliant, meaning they can be imported in the DAVIE application
- dictionaries
- class objects have a simple dictionary representation and are more efficient to work with in memory
- some attribute values can be dictionaries themselves
- because of cardinality, dictionary values can be a list of values or a list of dictionaries
- with rdf as true, the dictionary uses the RDF representation with full URIs as keys (and some of the values)
- dotnotation dictionaries
- these are similar to dictionaries, but they use dotnotation to access values
- as a result these are never nested and lists are converted to a string per convention
- pandas dataframes
- the popular pandas library is supported for reading and writing data, but it is not DAVIE compliant
- it uses the dotnotation convention
Converter class
The main class in this library is the OtlmowConverter class. This class is a facade class and has a couple of methods to convert between the different types of objects. The main methods are:
- to_objects: converts to instantiated otlmow class objects
- to_file: converts to a file
- to_dicts: converts to an iterable of dictionaries
- to_dotnotation_dicts: converts to an iterable of to_dotnotation dictionaries
- to_dataframe: converts to a pandas dataframe (or a dictionary holding multiple dataframes)
These methods can use any of the supported formats as input (subject). The methods determine the format of the subject and convert it to the desired format.
There are also from_A_to_B methods (i.e. from_dicts_to_objects) where either A or B are otlmow class objects. These methods are more efficient as they do not need to determine the format of the subject.
Installation and requirements
OTLMOW-Converter has a couple of dependencies besides the standard Python libraries. It depends on another OTLMOW package: otlmow-model. These libraries will be automatically installed when installing this library. Currently, you need at least Python version 3.8 to use this library.
To install the OTL MOW project into your Python project, use pip to install it:
pip install otlmow_converter
To upgrade an existing installation use:
pip install otlmow_converter --upgrade
Code examples and usage
See the Readme notebook
Supported file formats
The following file formats are supported in OtlmowConverter
File format | Read | Write | DAVIE compliant |
---|---|---|---|
CSV | Yes | Yes | Yes |
Excel | Yes | Yes | Yes |
JSON | Yes | Yes | Yes |
GeoJSON | Yes | Yes | Yes |
JSON-LD | Yes | Yes | No |
Pandas Dataframe | Yes | Yes | No |
TTL | No | Yes | No |
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 Distributions
Built Distribution
Hashes for otlmow_converter-1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0161ccb5303bdbe05de951eaadad864eddfbfa0688a95f1eeec63eb8d997e1c1 |
|
MD5 | 9452d5eba426db0832b83603a890dc7c |
|
BLAKE2b-256 | 6022b474a0b6abad77601dc19cefa92c2c35491dcaea6f0187c08ab5784538f3 |