def grouper(n, iterable, fillvalue=None):
    """Collect data into fixed-length chunks or blocks"""
args = [iter(iterable)] * n
return zip_longest(fillvalue=fillvalue, *args)
python: is there a library function for chunking an input stream?