def asnamedtuple(nt, row, missing=None):
    try:
        return nt(*row)
    except __HOLE__:
        # row may be long or short
        # expected number of fields
        ne = len(nt._fields)
        # actual number of values
        na = len(row)
        if ne > na:
            # pad short rows
            padded = tuple(row) + (missing,) * (ne-na)
            return nt(*padded)
        elif ne < na:
            # truncate long rows
            return nt(*row[:ne])
        else:
            raise
dataset/ETHPy150Open alimanfoo/petl/petl/util/base.py/asnamedtuple