import csv


def read_csv_file(filename, key_col, data_col):
    """Read data from a CSV file, get 'key_col' and 'data_col' columns.

    Returns ((key[0], data[0]), ...).
    """

    # Start reading the CSV file
    data = []
    fd = open(filename, 'r')
    csv_reader = csv.reader(fd)

    # Get header row, calculate required column indices
    h = next(csv_reader)
    header = [x.strip() for x in h]
    if key_col not in header:
        msg = ("Column '%s' not in file %s"
               % (key_col, filename))

        fd.close()
        raise Exception(msg)
    if data_col not in header:
        msg = ("Column '%s' not in file %s"
               % (data_col, filename))

        fd.close()
        raise Exception(msg)

    key_index = header.index(key_col)
    data_index = header.index(data_col)

    # read data, extract columns, save
    result = []
    for line in csv_reader:
        try:
            key_data = line[key_index].strip()
            data_data = line[data_index].strip()
            result.append((key_data, data_data))
        except:
            pass

    fd.close()

    return result