def grouper(iterable, n, fillvalue=None):
    """
    Collect data into fixed-length chunks or blocks.
    """
    args = [iter(iterable)] * n
    from itertools import zip_longest
    return zip_longest(*args, fillvalue=fillvalue)
