def read_label_map(description2label_txt):
    """Reads a label map text file into a dictionary (map)
    """
    description2label = {}
    f = open(description2label_txt, 'rb')
    s = f.read().decode('ISO-8859-1')
    lines = s.splitlines()
    lines = lines[1:]  # skip header

    for line in lines:
        line = line.strip()
        if not line:
            continue

        # convert line to fields
        fields = line.split(';')
        if len(fields) < 2:
            continue

        # read description
        description = fields[0].strip().lower()

        # read label
        label = fields[1].strip()
        if label.lower() == 'nan':
            continue
        label = label.replace(' ', '_').replace('/', '').replace('-', '')

        # add to dict
        description2label[description] = label.strip().lower()

    return description2label