def filechunk ( f , chunksize ) : while True : chunk = tuple ( itertools . islice ( f , chunksize ) ) if not chunk : return yield np . loadtxt ( iter ( chunk ) , dtype = np . float64 )
read huge text file in chunks python
Iterator that allow for piecemeal processing of a file .
def filechunk(f, chunksize):
    """Iterator that allow for piecemeal processing of a file."""
    while True:
        chunk = tuple(itertools.islice(f, chunksize))
        if not chunk:
            return
        yield np.loadtxt(iter(chunk), dtype=np.float64)