import re


def get_column_description_index(file_path):
    """Returns a dictionary of {description:column index} for a pandora file

    See https://regex101.com/r/gAjFtL/1 for an in-depth explanation of the regex used

    Returns two groups; group 1 is the column number, group 2 is the description.

    :param file_path: The path to the pandora data
    :type file_path: str

    :returns: The dictionary of {description:column index} suitable for passing to get_column_from_description
    :rtype: dict{str:int}
    """
    # See https://regex101.com/r/gAjFtL/1 for an in-depth explanation of this regex
    # Returns two groups; group 1 is the column number, group 2 is the description.
    searcher = re.compile(r"Column ([0-9]+): (.*)")
    with open(file_path, 'r', encoding="Latin-1") as pandora_file:
        pandora_text = pandora_file.read()
    groups = searcher.findall(pandora_text)
    column_dict = {column_description: int(column_index) for column_index, column_description in groups}
    return column_dict