Api Package
The api
package contains all the methods to load data into SDMXthon.
Read SDMX
- sdmxthon.api.api.read_sdmx(sdmx_file, validate=False, use_dataset_id=False) Message
Read SDMX performs the operation of reading a SDMX Data and SDMX metadata files in XML or CSV format. URLs could be used.
- Parameters:
sdmx_file – Path, URL or SDMX file as string
validate – Validation of the XML file against the XSD (default: False)
use_dataset_id – Use the DataSetID as key in output (default: True)
- Returns:
A
Message
object
Get Datasets
- sdmxthon.api.api.get_datasets(path_to_data, path_to_metadata, validate=True, remove_empty_columns=True)
GetDatasets performs the operation of reading a SDMX Data and SDMX metadata files. URLs could be used.
- Parameters:
path_to_data – Path, URL or SDMX data file as string
path_to_metadata – Path or URL to the SDMX metadata file
validate – Validation of the XML file against the XSD (default: True)
remove_empty_columns – Removes empty columns on output pd.Dataframe
- Returns:
A
Dataset
object or a dict ofDatasets
Get Pandas DF
- sdmxthon.api.api.get_pandas_df(path_to_data, validate=True, remove_empty_columns=True, use_dataset_id=False)
GetPandasDF reads all observations in a SDMX file as Pandas Dataframe(s)
- Parameters:
path_to_data – Path, URL or SDMX data file as string
validate – Validation of the XML file against the XSD (default: True)
remove_empty_columns – Removes empty columns on output pd.Dataframe
use_dataset_id – Use the DataSetID as key in output (default: False)
- Returns:
A dict of Pandas Dataframe
XML To CSV
- sdmxthon.api.api.xml_to_csv(data, output_path=None, validate=True, remove_empty_columns=True, **kwargs)
XML to CSV transforms a SDMX file into a CSV. Saves the file on disk or .zip of CSV. If the SDMX data file has only a Dataset and output_path is ‘’, it returns a StringIO object. Kwargs are supported.
- Parameters:
data – Path, URL or SDMX file as string (Data file)
output_path – Path to save the CSV (default: None)
validate – Validation of the XML file against the XSD (default: True)
remove_empty_columns – Removes empty columns on output pd.Dataframe
kwargs – Kwargs for to_csv
- Returns:
A StringIO object if output_path is ‘’
Upload metadata to Fusion Metadata Registry
- sdmxthon.api.api.upload_metadata_to_fmr(data: (<class 'str'>, <class 'os.PathLike'>), host: str = 'localhost', port: int = 8080, user: str = 'root', password: str = 'password', use_https: bool = False)
Uploads metadata to FMR instance
- Parameters:
data (str or a path to a file) – Either a string containing SDMX metadata or a path to a file with SDMX metadata
host (str) – The FMR instance host (default is ‘localhost’)
port (str) – The FMR instance port (default is 8080)
user (str) – The username for authentication (default is ‘root’)
password (str) – The password for authentication (default is ‘password’)
use_https (bool) – A boolean indicating whether to use HTTPS (default is False)
- Exception:
Exception with error details if upload fails