build_value_map()

Create a pysdmx ValueMap object mapping a source value to a target value.

Usage

Source

build_value_map(
    source,
    target,
    valid_from=None,
    valid_to=None,
)

Parameters

source: str

The source value to map.

target: str

The target value to map to.

valid_from: datetime | None = None

Start of business validity for the mapping.

valid_to: datetime | None = None
End of business validity for the mapping.

Returns

ValueMap
A pysdmx ValueMap object representing the mapping.

Raises

ValueError

If source or target is empty.

TypeError
If source or target is not a string.

Examples

>>> from datetime import datetime
>>> vm = build_value_map("BE", "BEL")
>>> isinstance(vm, ValueMap)
True
>>> vm.source
'BE'
>>> vm.target
'BEL'
>>> vm2 = build_value_map("DE", "GER", valid_from=datetime(2020, 1, 1))
>>> vm2.valid_from.year
2020