def grouper(iterable, n):
    """Collect data into fixed-length chunks or blocks"""
    block = []
    for index, item in enumerate(iterable, start=1):
        block.append(item)
        if index % n == 0:
            yield block
            block.clear()
    yield block
