Transform CLI

This module provides CLI commands to transform downloaded data.

abgeordnetenwatch_data(legislature_id=ARGUMENT_LEGISLATURE_ID, dry=OPTION_DRY, data_path=OPTION_DATA_PATH)

Transform abgeordnetenwatch data.

Parameters:
  • legislature_id (int, default: ARGUMENT_LEGISLATURE_ID ) –

    The ID of the legislature to transform data for. Defaults to 111.

  • dry (bool, default: OPTION_DRY ) –

    If True, don't actually perform the transformation. Defaults to False.

  • data_path (str, default: OPTION_DATA_PATH ) –

    The path to the data directory. Defaults to "data".

Examples:

To transform data for legislature 161: bundestag transform abgeordnetenwatch-data 161

Source code in src/bundestag/cli/transform.py
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
@app.command(help="Transform abgeordnetenwatch data.")
def abgeordnetenwatch_data(
    legislature_id: int = ARGUMENT_LEGISLATURE_ID,
    dry: bool = OPTION_DRY,
    data_path: str = OPTION_DATA_PATH,
):
    """Transform abgeordnetenwatch data.

    Args:
        legislature_id (int): The ID of the legislature to transform data for. Defaults to 111.
        dry (bool, optional): If `True`, don't actually perform the transformation. Defaults to False.
        data_path (str, optional): The path to the data directory. Defaults to "data".

    Examples:
        To transform data for legislature 161:
        `bundestag transform abgeordnetenwatch-data 161`
    """
    _paths = paths.get_paths(data_path)

    _transform_abgeordnetenwatch(
        legislature_id=legislature_id,
        raw_path=_paths.raw_abgeordnetenwatch,
        preprocessed_path=_paths.preprocessed_abgeordnetenwatch,
        dry=dry,
    )

bundestag_sheets(dry=OPTION_DRY, data_path=OPTION_DATA_PATH, sheet_source=typer.Option(SheetsSource.json_file.value, help=f'bundestag_sheet specific parameter. Switch between xlsx uri sources. Options: {[(k.value) for k in SheetsSource]}'))

Transform bundestag sheet data.

Parameters:
  • dry (bool, default: OPTION_DRY ) –

    If True, don't actually perform the transformation. Defaults to False.

  • data_path (str, default: OPTION_DATA_PATH ) –

    The path to the data directory. Defaults to "data".

  • sheet_source (Source, default: Option(value, help=f'bundestag_sheet specific parameter. Switch between xlsx uri sources. Options: {[(value) for k in Source]}') ) –

    The source for sheet URIs. Defaults to "json_file".

Examples:

To transform the data using the default JSON file source: bundestag transform bundestag-sheets

Source code in src/bundestag/cli/transform.py
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
@app.command(help="Transform bundestag sheet data.")
def bundestag_sheets(
    dry: bool = OPTION_DRY,
    data_path: str = OPTION_DATA_PATH,
    sheet_source: SheetsSource = typer.Option(
        SheetsSource.json_file.value,
        help=f"bundestag_sheet specific parameter. Switch between xlsx uri sources. Options: {[k.value for k in SheetsSource]}",
    ),
):
    """Transform bundestag sheet data.

    Args:
        dry (bool, optional): If `True`, don't actually perform the transformation. Defaults to False.
        data_path (str, optional): The path to the data directory. Defaults to "data".
        sheet_source (SheetsSource, optional): The source for sheet URIs. Defaults to "json_file".

    Examples:
        To transform the data using the default JSON file source:
        `bundestag transform bundestag-sheets`
    """
    _paths = paths.get_paths(data_path)

    _transform_bundestag_sheets(
        html_dir=_paths.raw_bundestag_html,
        sheet_dir=_paths.raw_bundestag_sheets,
        preprocessed_path=_paths.preprocessed_bundestag,
        dry=dry,
        source=sheet_source,
    )