read_mapping()

Read a JSON mapping file and parse its content into DataFrames.

Usage

Source

read_mapping(path)

The function processes JSON data with four main keys:

1. ``schema_version``: The version of the mapping schema.
2. ``dsd_id``: The Data Structure Definition ID.
3. ``components``: A flat structure converted into a DataFrame.
4. ``representation``: Multiple sub-keys, each converted into a
   separate DataFrame. Empty sub-keys are skipped.

All occurrences of the string "NA" are converted to pd.NA.

Parameters

path: str
The file path to the JSON file to be parsed.

Returns

dict

A dictionary where:

  • schema_version is stored under key 'schema_version'.
  • dsd_id is stored under key 'dsd_id'.
  • The components DataFrame is stored under key 'components'.
  • Each valid representation sub-key is stored as a DataFrame under its corresponding key.

Raises

ValueError
If required keys are missing or have unexpected formats.