MCPcopy Index your code
hub / github.com/KnowledgeXLab/LeanRAG / write_jsonl_chunk

Function write_jsonl_chunk

tools/io_file.py:473–486  ·  view source on GitHub ↗

写入JSONL文件的某一块。 参数: - file_path (str): 文件路径。 - chunk (list): 要写入的数据块。 - mode (str): 写入模式,默认为 'a'(追加模式),可以选择 'w'(覆盖模式)。 - encoding (str): 写入文件的编码格式,默认为 'utf-8'。

(file_path, chunk, mode, encoding='utf-8')

Source from the content-addressed store, hash-verified

471
472
473def write_jsonl_chunk(file_path, chunk, mode, encoding='utf-8'):
474 """
475 写入JSONL文件的某一块。
476
477 参数:
478 - file_path (str): 文件路径。
479 - chunk (list): 要写入的数据块。
480 - mode (str): 写入模式,默认为 'a'(追加模式),可以选择 'w'(覆盖模式)。
481 - encoding (str): 写入文件的编码格式,默认为 'utf-8'
482 """
483 with open(file_path, mode, encoding=encoding) as f:
484 for entry in chunk:
485 json.dump(entry, f, ensure_ascii=False)
486 f.write('\n')
487
488
489def write_csv(file_path, data, mode, chunk_size, encoding='utf-8'):

Callers

nothing calls this directly

Calls 1

writeMethod · 0.80

Tested by

no test coverage detected