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

Function read_csv

tools/io_file.py:169–187  ·  view source on GitHub ↗

读取CSV文件。 参数: - file_path (str): 文件路径。 - chunk_size (int): 当文件大于此大小时,使用多线程读取。 - encoding (str): 文件编码格式,默认为 'utf-8'。 返回: - DataFrame: 读取的CSV文件内容。

(file_path, chunk_size, encoding='utf-8')

Source from the content-addressed store, hash-verified

167
168
169def read_csv(file_path, chunk_size, encoding='utf-8'):
170 """
171 读取CSV文件。
172
173 参数:
174 - file_path (str): 文件路径。
175 - chunk_size (int): 当文件大于此大小时,使用多线程读取。
176 - encoding (str): 文件编码格式,默认为 'utf-8'
177
178 返回:
179 - DataFrame: 读取的CSV文件内容。
180 """
181 file_size = os.path.getsize(file_path)
182 if file_size > chunk_size:
183 logger.info(f"文件 {file_path} 较大,启用多线程读取")
184 return read_csv_multithread(file_path, chunk_size, encoding)
185 else:
186 logger.info(f"读取CSV文件: {file_path}")
187 return pd.read_csv(file_path, encoding=encoding)
188
189
190def read_csv_multithread(file_path, chunk_size, encoding='utf-8'):

Callers 1

readFunction · 0.85

Calls 1

read_csv_multithreadFunction · 0.85

Tested by

no test coverage detected