[python]大文件阅读器

def process_lines(lines):
    # 在这里定义你想对这些行执行的处理逻辑
    for line in lines:
        print(line.strip())  # 例如,这里只是简单地打印每一行

def read_large_file_in_chunks(file_path, chunk_size=1000):
    with open(file_path, 'r', encoding='utf-8') as file:
        while True:
            lines = [file.readline() for _ in range(chunk_size)]
            if not lines[0]:
                break
            process_lines(lines)
            input("按回车键加载更多...")

if __name__ == "__main__":
    file_path = '1000G.json'  # 替换为你实际的文件路径
    read_large_file_in_chunks(file_path)