Commit 91c5e98b authored by Asitha Senanayake's avatar Asitha Senanayake
Browse files

feat: add support for standard dictionary v4.2

parent c39147d1
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -557,7 +557,7 @@ def convert_to_text(dataframe, dictionary=None):
        convert to numeric fields to required precision. The values from the
        dictionary will override those already in the UNIT and TYPE rows in the
        dataframe. A standard dictionary can be picked using the one of the
        following strings '4.1.1', '4.1', '4.0.4', '4.0.3', '4.0'.
        following strings '4.2', '4.1.1', '4.1', '4.0.4', '4.0.3', '4.0'.

    Returns
    -------
@@ -591,7 +591,7 @@ def convert_to_text(dataframe, dictionary=None):

    else:
        # Read dictionary file
        if dictionary in ['4.1.1', '4.1', '4.0.4', '4.0.3', '4.0']:
        if dictionary in ['4.2', '4.1.1', '4.1', '4.0.4', '4.0.3', '4.0']:
            # Filepath to the standard dictionary will be picked based on version
            # number if a valid version number is provided. If it is not specified
            # at all, then the filepath will be selected based on the value of
@@ -741,7 +741,7 @@ def check_file(filepath_or_buffer, standard_AGS4_dictionary=None, rename_duplica
        file or StringIO) to be checked.
    standard_AGS4_dict : str
        Path to .ags file with standard AGS4 dictionary or version number
        (should be one of '4.1.1', '4.1', '4.0.4', '4.0.3', '4.0').
        (should be one of '4.2', '4.1.1', '4.1', '4.0.4', '4.0.3', '4.0').
    rename_duplicate_headers: bool, default=True
        Rename duplicate headers if found. Neither AGS4 tables nor Pandas
        dataframes allow duplicate headers, therefore a number will be appended
@@ -865,7 +865,7 @@ def check_file(filepath_or_buffer, standard_AGS4_dictionary=None, rename_duplica
        # Dictionary Based Checks

        # Pick path to standard dictionary
        if standard_AGS4_dictionary in [None, '4.1.1', '4.1', '4.0.4', '4.0.3', '4.0']:
        if standard_AGS4_dictionary in [None, '4.2', '4.1.1', '4.1', '4.0.4', '4.0.3', '4.0']:
            # Filepath to the standard dictionary will be picked based on version
            # number if a valid version number is provided. If it is not specified
            # at all, then the filepath will be selected based on the value of
+1 −1
Original line number Diff line number Diff line
@@ -169,7 +169,7 @@ def convert(input_file, output_file, format_columns, dictionary, rename_duplicat
@click.option('-d', '--dictionary_path', type=click.File('r'), default=None,
              help="Path to AGS4 dictionary file.")
@click.option('-v', '--dictionary_version',
              type=click.Choice(['4.1.1', '4.1', '4.0.4', '4.0.3', '4.0']),
              type=click.Choice(['4.2', '4.1.1', '4.1', '4.0.4', '4.0.3', '4.0']),
              help='Version of standard dictionary to use. (Warning: Overrides version specified in TRAN_AGS '
                   'and custom dictionary specifed by --dictionary_path)')
@click.option('-e', '--encoding',
+3 −2
Original line number Diff line number Diff line
@@ -42,7 +42,8 @@ STANDARD_DICT_FILES = {'4.0': 'Standard_dictionary_v4_0_3.ags',
                       '4.0.3':   'Standard_dictionary_v4_0_3.ags',
                       '4.0.4':   'Standard_dictionary_v4_0_4.ags',
                       '4.1':     'Standard_dictionary_v4_1.ags',
                       '4.1.1':   'Standard_dictionary_v4_1_1.ags'
                       '4.1.1':   'Standard_dictionary_v4_1_1.ags',
                       '4.2':     'Standard_dictionary_v4_2.ags'
                       }

# Dictionary version to use if valid version not provided or found in TRAN table
@@ -191,7 +192,7 @@ def pick_standard_dictionary(tables=None, dict_version=None):
        Dictionary of Pandas DataFrames with all AGS4 data in file
    dict_version : str, optional
        String with version number to override TRAN_AGS. Should be one of
        '4.1.1', 4.1', '4.0.4', 4.0.3', '4.0'.
        '4.2', 4.1.1', 4.1', '4.0.4', 4.0.3', '4.0'.

    Returns
    -------