def iterunpackdict(table, field, keys, includeoriginal, samplesize, missing):

    # set up
    it = iter(table)
    hdr = next(it)
    flds = list(map(text_type, hdr))
    fidx = flds.index(field)
    outhdr = list(flds)
    if not includeoriginal:
        del outhdr[fidx]

    # are keys specified?
    if not keys:
        # need to sample to find keys
        sample = list(itertools.islice(it, samplesize))
        keys = set()
        for row in sample:
            try:
                keys |= set(row[fidx].keys())
            except AttributeError:
                pass
        it = itertools.chain(sample, it)
        keys = sorted(keys)
    outhdr.extend(keys)
    yield tuple(outhdr)

    # generate the data rows
    for row in it:
        outrow = list(row)
        if not includeoriginal:
            del outrow[fidx]
        for key in keys:
            try:
                outrow.append(row[fidx][key])
            except (__HOLE__, KeyError, TypeError):
                outrow.append(missing)
        yield tuple(outrow)
dataset/ETHPy150Open alimanfoo/petl/petl/transform/unpacks.py/iterunpackdict