Iterate chunks of size chunk_size from a file-like object
547332
def iterate_chunks(file, chunk_size):
    
    chunk = file.read(chunk_size)
    while chunk:
        yield chunk
        chunk = file.read(chunk_size)
1055380
def iter_chunks(chunk_size, iterator):
    ""
    iterator = iter(iterator)
    while True:
        next_chunk = _take_n(chunk_size, iterator)
        # If len(iterable) % chunk_size == 0, don't return an empty chunk.
        if next_chunk:
            yield next_chunk
        else:
            break
1329316
def read_chunked(self):
        """"""
        self._load_metadata()
        for i in range(self.npartitions):
            yield self._get_partition(i)
1000715
def file_chunk(filename, size=_BUFFERING):
    

    def chunks():
        with open(filename, "rb", _BUFFERING) as fd:
            buf = fd.read(size)
            while buf:
                yield buf
                buf = fd.read(size)
    return chunks
133716
def determine_num_chunks(chunk_size, file_size):
        
        if file_size == 0:
            return 1
        return int(math.ceil(float(file_size) / float(chunk_size)))
24047
def read_in_chunks(file_obj, chunk_size):
    """"""
    offset = 0
    while True:
        data = file_obj.read(chunk_size)
        if not data:
            break
        yield data, offset
        offset += len(data)
650278
def _fetch_chunker(self, uri, chunk_size, size, obj_size):
        
        pos = 0
        total_bytes = 0
        size = size or obj_size
        max_size = min(size, obj_size)
        while True:
            endpos = min(obj_size, pos + chunk_size - 1)
            headers = {"Range": "bytes=%s-%s" % (pos, endpos)}
            resp, resp_body = self.api.method_get(uri, headers=headers,
                    raw_content=True)
            pos = endpos + 1
            if not resp_body:
                # End of file
                return
            yield resp_body
            total_bytes += len(resp_body)
            if total_bytes >= max_size:
                return
1187954
def _file_chunks(self, data, chunk_size):
        
        for i in xrange(0, len(data), chunk_size):
            yield self.compressor(data[i:i+chunk_size])
1140249
def parseChunk(self, chunk, size, terminate):
        
        ret = libxml2mod.xmlParseChunk(self._o, chunk, size, terminate)
        return ret
819035
def chunks(l, n):
    
    for i in _range(0, len(l), n):
        yield l[i:i + n]
903009
def chunks(items, size):
    
    return [items[i:i+size] for i in range(0, len(items), size)]
375098
def _chunks(l, ncols):
    """"""
    assert isinstance(ncols, int), "ncols must be an integer"
    for i in range(0, len(l), ncols):
        yield l[i: i+ncols]
761323
def array(self, size_chunk, start, bytesize):
        ''' 
        '''

        with open(self.img, 'rb') as f1:
            f1.seek(self.start_byte + start * self.bytesize)
            data = f1.read(size_chunk * self.bytesize)
            Z = np.fromstring(data, dtype=self.dtype, count=size_chunk)
            if self.grid == 'LOLA':
                return Z * float(self.SCALING_FACTOR)
            else:
                return Z
420465
def load_chunk(filename, bounds, encoding='utf8', slow=False):
    
    if slow:
        return _load_chunk_slow(filename, bounds, encoding)

    with open(filename, 'rb') as f:
        f.seek(bounds.byte_start)
        size = bounds.byte_end - bounds.byte_start
        return f.read(size).decode(encoding)
464024
def chunk_iter(iterable, chunk_size):
    ''' '''
    while True:
        chunk = []
        try:
            for _ in range(chunk_size): chunk.append(next(iterable))
            yield chunk
        except StopIteration:
            if chunk: yield chunk
            break
511662
def iterchunks(data, chunksize):
    
    offt = 0
    while offt < len(data):
        yield data[offt:offt+chunksize]
        offt += chunksize
1196588
def iter_chunks(chunksize, *iterables):
    """"""
    iterables = iter(zip(*iterables))

    while 1:
        chunk = tuple(islice(iterables, chunksize))

        if not chunk:
            return

        yield chunk