def __iter__(self):

        # construct output header
        if isinstance(self.field, (tuple, list)):
            outhdr = tuple(self.field) + ('count', 'frequency')
        else:
            outhdr = (self.field, 'count', 'frequency')
        yield outhdr

        # count values
        counter = valuecounter(self.table, *self.field, missing=self.missing)
        counts = counter.most_common()  # sort descending
        total = sum(c[1] for c in counts)

        if len(self.field) > 1:
            for c in counts:
                yield tuple(c[0]) + (c[1], float(c[1])/total)
        else:
            for c in counts:
                yield (c[0], c[1], float(c[1])/total)
dataset/ETHPy150Open alimanfoo/petl/petl/util/counting.py/ValueCountsView.__iter__/original