def txtToDict(filename, key=None, sep="\t"):

    # Please see function in readDict()
    count = 0
    result = {}
    valueidx, keyidx = False, False
    field_names = []

    with open(filename, "r") as fh:
        for line in fh:
            if line.startswith("#"):
                continue
            if count == 0:
                fieldn = 0
                for rawfield in line.split(sep):
                    field = rawfield.strip()
                    if field == key:
                        keyidx = fieldn
                    field_names.append(field)
                    fieldn += 1

                if not keyidx:
                    raise ValueError("key name not found in header")
                # if not valueidx:
                #   raise ValueError(
                #     "value name not found in header")
            else:
                fields = [x.strip() for x in line.split(sep)]
                fieldn = 0
                thiskey = fields[keyidx]
                result[thiskey] = {}
                for field in fields:
                    if fieldn == keyidx:
                        pass
                    else:
                        colkey = field_names[fieldn]
                        result[thiskey][colkey] = field
                    fieldn += 1
            count += 1

    return(result)
Insure that DiscoveryError is raised when a test which raises an unusual exception upon import is discovered.
dataset/ETHPy150Open CGATOxford/cgat/CGAT/IOTools.py/txtToDict--crossover with--dataset/ETHPy150Open Yelp/Testify/test/discovery_failure_test.py/DiscoveryFailureUnknownErrorTestCase.test_discover_test_with_unknown_import_error