@classmethod
    def wrap_all_rows(cls, tables):
        ret = []
        for name, rows in tables:
            rows = list(rows)
            if rows and (not hasattr(rows[0], '__iter__') or isinstance(rows[0], basestring)):
                # `rows` is actually just a single row, so wrap it
                rows = [rows]
            ret.append(
                (name, [cls(row) for row in rows])
            )
        return ret
Take a list of tuples (name, SINGLE_ROW) or (name, (ROW, ROW, ...))
dataset/ETHPy150Open dimagi/commcare-hq/corehq/ex-submodules/couchexport/export.py/FormattedRow.wrap_all_rows