General Reader
The pysdmx general reader is a set of methods to read any SDMX message, regardless of the format or version.
Tutorial on reading SDMX Data messages.
Tutorial on reading SDMX Structure messages.
Formats and Versions Supported
List of formats and versions supported by the general reader:
Read SDMX
This method allows you to read any SDMX message, regardless of the format or version as long as it is supported.
- pysdmx.io.read_sdmx(sdmx_document, validate=True)
Reads any SDMX message and extracts its content.
Check the formats supported
- Parameters:
sdmx_document (
Union
[str
,Path
,BytesIO
]) – Path to file (pathlib.Path), URL, or string.validate (
bool
) – Validate the input file (only for SDMX-ML).
- Raises:
Invalid – If the file is empty or the format is not supported.
- Return type:
Get Datasets
This method allows you to retrieve Pandas Datasets from a Data message, and add the related metadata
as a Schema object: pysdmx.model.dataflow.Schema()
.
- pysdmx.io.get_datasets(data, structure=None, validate=True)
Reads a data message and a structure message and returns a dataset.
This method reads a data message and an optional structure message, and returns a sequence of Datasets. Check the formats supported
The resulting datasets will have their structure assigned, this is required for:
Data validation against its structure
Data writing in SDMX-ML Structure Specific with DimensionAtObservation not equal to AllDimensions or Generic formats
Execution of VTL scripts over PandasDataset
- Parameters:
data (
Union
[str
,Path
,BytesIO
]) –Path to file (pathlib.Path), URL, or string for the data message.
structure (
Union
[str
,Path
,BytesIO
,None
]) –Path to file (pathlib.Path), URL, or string for the structure message, if needed.
validate (
bool
) – Validate the input file (only for SDMX-ML).
- Raises:
Invalid – If the data message is empty or the related data structure (or dataflow with its children) is not found.
NotFound – If the related data structure (or dataflow with its children) is not found.
- Return type:
Sequence
[Dataset
]