Write standard formats¶
The term write means to convert sdmx.message and sdmx.model objects
specifically to the standard Standard formats.
See Convert from/to SDMX for conversion to data structures not described by the standards.
writer.csv: Write SDMX-CSV¶
Added in version 2.9.0.
See to_csv().
SDMX-CSV writer.
writer.xml: Write SDMX-ML¶
Added in version 1.1.
See to_xml().
SDMX-ML v2.1 writer.
- sdmx.writer.xml.i11lstring(obj, name) list[_Element][source]¶
InternationalString.
Returns a list of elements with name name.
- sdmx.writer.xml.identifiable(obj: IdentifiableArtefact, *args, **kwargs) _Element[source]¶
Write
IdentifiableArtefact.Unless the keyword argument _with_urn is
False, a URN is generated for objects lacking one, and forwarded toannotable()
- sdmx.writer.xml.reference(obj, parent=None, tag=None, *, style: Literal['Ref', 'URN'])[source]¶
Write a reference to obj.
Todo
Currently other functions in
writer.xmlall pass the style argument to this function. As an enhancement, allow user or automatic selection of different reference styles.
Writer API¶
- class sdmx.writer.base.BaseWriter(format_name)[source]¶
Base class for recursive writers.
Usage:
Create an instance of this class.
Use
register()in the same manner as Python’s built-infunctools.singledispatch()to decorate functions that certain types ofsdmx.modelorsdmx.messageobjects.Call
recurse()to kick off recursive writing of objects, including from inside other functions.
Example
>>> MyWriter = BaseWriter('my')
>>> @MyWriter.register >>> def _(obj: sdmx.model.ItemScheme): >>> ... code to write an ItemScheme ... >>> return result
>>> @MyWriter.register >>> def _(obj: sdmx.model.Codelist): >>> ... code to write a Codelist ... >>> return result