def readchunks(path, encoding="utf-8", skiplines=None, chunksize=None, strip='right'):
    """skip n lines and fetch the next n lines as a chunk, and repeat fetching.
    
    :param skiplines: default None, skip first n lines
    :param chunksize: default None (size-1 chunk), lines chunk size
    :param strip: default None, avaliable option 'left', 'right', 'both'
    
    **中文文档**
    
    跳过前#skiplines行, 每次读取#chunksize行yield。可对字符串进行strip预处理。
    """
    strip_method = str(strip).lower()
    if strip_method in _strip_method_mapping:
        strip_func = _strip_method_mapping[strip_method]
    else:
        raise ValueError("'strip' keyword has to be one of "
                         "None, 'left', 'right', 'both'.")
        
    with open(path, "rb") as file:
        if skiplines:
            for _ in range(skiplines):
                next(file)
            
        if chunksize is None:
            chunksize = 1
        elif not isinstance(chunksize, int_type): 
            raise ValueError("'chunksize' has to be None or an integer.")
        
        chunk = list()
        while 1:
            for _ in range(chunksize):
                chunk.append(strip_func(next(file).decode(encoding)))
            if len(chunk) < chunksize:
                break
            yield chunk
            chunk = list()
        yield chunk
def readchunks ( path , encoding = "utf-8" , skiplines = None , chunksize = None , strip = 'right' ) : strip_method = str ( strip ) . lower ( ) if strip_method in _strip_method_mapping : strip_func = _strip_method_mapping [ strip_method ] else : raise ValueError ( "'strip' keyword has to be one of " "None, 'left', 'right', 'both'." ) with open ( path , "rb" ) as file : if skiplines : for _ in range ( skiplines ) : next ( file ) if chunksize is None : chunksize = 1 elif not isinstance ( chunksize , int_type ) : raise ValueError ( "'chunksize' has to be None or an integer." ) chunk = list ( ) while 1 : for _ in range ( chunksize ) : chunk . append ( strip_func ( next ( file ) . decode ( encoding ) ) ) if len ( chunk ) < chunksize : break yield chunk chunk = list ( ) yield chunk
skip n lines and fetch the next n lines as a chunk, and repeat fetching.
    
    :param skiplines: default None, skip first n lines
    :param chunksize: default None (size-1 chunk), lines chunk size
    :param strip: default None, avaliable option 'left', 'right', 'both'
    
    **中文文档**
    
    跳过前#skiplines行, 每次读取#chunksize行yield。可对字符串进行strip预处理。