Skip to content

get_fields_from_datastream

Functions:

Name Description
get_fields_from_datastream

Extracts fields from the datastream.

Attributes#

Classes#

Functions#

get_fields_from_datastream #

get_fields_from_datastream(
    datastream: str,
) -> Dict[str, str]

Extracts fields from the datastream.

WARNING: this only works for the default datastream template.

Source code in tsdat/utils/get_fields_from_datastream.py
def get_fields_from_datastream(datastream: str) -> Dict[str, str]:
    """Extracts fields from the datastream.

    WARNING: this only works for the default datastream template.
    """
    datastream_template = Template(TEMPLATE_REGISTRY["datastream"])
    fields = datastream_template.extract_substitutions(datastream)
    if fields is None:
        return {}
    return {k: v for k, v in fields.items() if v is not None}