Converting between different representations#
LinkML allows you to specify schemas for data in a variety of forms:
JSON / YAML
Python object models
Spreadsheets and tabular data
The process of loading from one of these formats into an internal representation is called loading. The opposite process, going from an internal representation into an external format is called dumping
The “native” form for LinkML can be considered JSON/YAML.
See PersonSchema/data for example toy data files
Part 6 of the LinkML specification provides a more formal treatment
Loading from and dumping to JSON#
You can use the linkml-convert script to load or dump from JSON into another representation.
Dumping to JSON can be lossy; if your objects contain typing information that cannot be inferred from range constraints.
For example, if you have a schema:
and a person object:
Then there is insufficient information to determine whether the internal representation of the organization the person is employed at should be instantiated as a NonProfit or a Corporation.
LinkML allows a slot to be set with designates_type, the value of which is a name of a class from the schema. However, the loaders currently do not yet make use of this when loading from JSON into the internal representation.
Loading from and dumping to YAML#
The native YAML representation for LinkML is essentially identical to JSON.
In future there may be support for a direct translation to YAML that utilizes YAML tags to encode typing information.
Loading from and dumping to RDF#
Loading and dumping works in a similar fashion for RDF. One difference is that the schema must be present as this contains crucial information for being able to map classes and slots to URIs.
See RDF for more details
Loading from and dumping to CSVs#
See CSVs for more details
Inferring missing values#
--infer flag can be provided to perform missing value inference
See advanced schemas for more information on inference
See developer docs for documentation of the relevant python classes