Code reference

Non-standard TDC Excel file format for collecting metadata.

Module data

README_TEXT

README text for the TDC metadata file format.

transport_data.org.metadata.spreadsheet.README_TEXT = 'This file is an unofficial, prototype TDC format for metadata.\nloosely imitates the Eurostat format. These files contain metadata (information\n*about* data) based on the SDMX information model, but their layout (sheet\nnames, columns, etc.) is not specified by the SDMX standard, hence ‘unofficial’.\n\nThis file has the following sheets.\n\nREADME\n======\n\nThis sheet.\n\nAttributes\n==========\n\n- One row per metadata attribute (or \'field\').\n- Columns for the name; description; and ID (short and machine-readable) of each\n  attribute. See these descriptions to learn what to write for each attribute.\n\nOne or more additional sheets\n=============================\n\n- The name (or title) of each sheet corresponds to the identity (ID) of the data\n  flow that is described by the metadata in that sheet.\n- In Column A, the name of the metadata attribute. Each name MUST exactly\n  match one appearing in the "Attributes" sheet. Some names MAY be omitted.\n- In Column B, the actual metadata. These may be empty.\n\nTEMPLATE\n========\n\nTo add information about additional data flows not included in existing sheets\n(above), you can copy and rename this sheet.\n'[source]

README text for the TDC metadata file format.

Functions

add_attributes(wb, msd)

Add an "Attributes" sheet to wb listing the metadata attributes from msd.

add_readme(wb)

Add a "README" sheet to wb.

add_template(wb, msd)

Add a "TEMPLATE" sheet to wb with a metadata template.

getdefault(is_, other)

Return an item from is_ matching other.

make_workbook([name])

Generate a openpyxl.Workbook for exchange of metadata.

parse_dimension(value)

Parse the description of a dimension from value.

read_workbook(path)

Read a metadata set from the workbook at path.

read_worksheet(ws, msd, cs_dims)

Read a metadata report from the worksheet ws.

update_dimension_descriptor(dsd, cs_dims, ...)

Update the DimensionDescriptor of dsd with concepts.

transport_data.org.metadata.spreadsheet.add_attributes(wb: Workbook, msd: v21.MetadataStructureDefinition)[source]

Add an “Attributes” sheet to wb listing the metadata attributes from msd.

transport_data.org.metadata.spreadsheet.add_readme(wb: Workbook) None[source]

Add a “README” sheet to wb.

transport_data.org.metadata.spreadsheet.add_template(wb: Workbook, msd: v21.MetadataStructureDefinition)[source]

Add a “TEMPLATE” sheet to wb with a metadata template.

transport_data.org.metadata.spreadsheet.getdefault(is_: ItemScheme, other: Item) Item[source]

Return an item from is_ matching other.

Several methods are attempted to match other with an existing item:

  1. ID of other is identical to that of an existing item.

  2. Transformed ID of other—in upper case, “ “ replaced with “_” is identical to that of an existing item.

  3. ID of other is in the annotation tdc-aka

transport_data.org.metadata.spreadsheet.make_workbook(name='sample.xlsx') None[source]

Generate a openpyxl.Workbook for exchange of metadata.

transport_data.org.metadata.spreadsheet.parse_dimension(value: str) List[Concept][source]

Parse the description of a dimension from value.

Supported values include:

  1. Multiple lines, with each line beginning “- “.

  2. A single line, with dimensions separated by “, “.

  3. A single dimension ID.

transport_data.org.metadata.spreadsheet.read_workbook(path: pathlib.Path) tuple[v21.MetadataSet, v21.ConceptScheme][source]

Read a metadata set from the workbook at path.

transport_data.org.metadata.spreadsheet.read_worksheet(ws: Worksheet, msd: v21.MetadataStructureDefinition, cs_dims: v21.ConceptScheme) v21.MetadataReport | None[source]

Read a metadata report from the worksheet ws.

Parameters:

msd – Metadata structure definition.

transport_data.org.metadata.spreadsheet.update_dimension_descriptor(dsd: DataStructureDefinition, cs_dims: ConceptScheme, *concepts) None[source]

Update the DimensionDescriptor of dsd with concepts.