Code reference¶
Utilities for sdmx.
Functions
|
Annotate the obj with information about how it was generated. |
|
Populate rs with MetadataAttributes corresponding to dataclass fields of cls. |
|
Helper function for making |
|
Read or adapt SDMX-CSV from path. |
|
Infer a data flow and arguments for |
- transport_data.util.sdmx.anno_generated(obj: sdmx.model.common.AnnotableArtefact) None[source]¶
Annotate the obj with information about how it was generated.
- transport_data.util.sdmx.fields_to_mda(cls: type, rs: sdmx.model.v21.ReportStructure, cs: sdmx.model.common.ConceptScheme | None = None) None[source]¶
Populate rs with MetadataAttributes corresponding to dataclass fields of cls.
Examples
>>> @dataclass ... class MDSExample: ... #: Foo ... #: ... #: Description of Foo. ... foo: str ... ... bar: int ... ... fields_to_mda(MDSExample)
In this example, two metadata attributes will be added to rs:
With id=”foo” and an annotation with id=”data-type” and text=”<class ‘str’>”. The concept identity for the metadata attribute will also have id=”foo”, name=”Foo”, and description=”Description of Foo.”
With id=”bar” and an annotation with id=”data-type” and text=”<class ‘int’>”.
- transport_data.util.sdmx.make_obs(row: pd.Series, dsd: sdmx.model.v21.DataStructureDefinition) sdmx.model.v21.Observation[source]¶
Helper function for making
sdmx.model.Observationobjects.
- transport_data.util.sdmx.read_csv(path: pathlib.Path, structure: sdmx.model.v30.Dataflow | sdmx.model.v30.DataStructureDefinition, adapt: dict | None = None) sdmx.message.DataMessage[source]¶
Read or adapt SDMX-CSV from path.
- Parameters:
path – A file in SDMX-CSV or CSV format.
structure – Data flow or data structure describing the contents of path.
adapt – Keyword arguments to
CSVAdapter. If given, the contents of path are adapted from a ‘simplified’ or ‘reduced’ CSV format to SDMX-CSV on-the-fly. See the class documentation for details.
- transport_data.util.sdmx.structure_from_csv(path: pathlib.Path) tuple[sdmx.model.v30.Dataflow, dict][source]¶
Infer a data flow and arguments for
read_csv()from path.- Returns:
with 2 elements:
dict, a value for theadaptargument ofread_csv().
- Return type:
Classes
|
Adapt CSV content from path into SDMX-CSV. |