MCPcopy Create free account
hub / github.com/KnowledgeXLab/LeanRAG / read_chunk

Function read_chunk

tools/io_file.py:151–166  ·  view source on GitHub ↗

读取文件的某个块。 参数: - file_path (str): 文件路径。 - start (int): 起始字节位置。 - end (int): 结束字节位置。 - encoding (str): 文件编码格式,默认为 'utf-8'。 返回: - str: 读取的块数据。

(file_path, start, end, encoding='utf-8')

Source from the content-addressed store, hash-verified

149
150
151def read_chunk(file_path, start, end, encoding='utf-8'):
152 """
153 读取文件的某个块。
154
155 参数:
156 - file_path (str): 文件路径。
157 - start (int): 起始字节位置。
158 - end (int): 结束字节位置。
159 - encoding (str): 文件编码格式,默认为 'utf-8'
160
161 返回:
162 - str: 读取的块数据。
163 """
164 with open(file_path, 'r', encoding=encoding) as f:
165 f.seek(start)
166 return f.read(end - start)
167
168
169def read_csv(file_path, chunk_size, encoding='utf-8'):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected