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

Function print_file

tools/tools.py:234–242  ·  view source on GitHub ↗
(infile, n=10)

Source from the content-addressed store, hash-verified

232 output_file.close()
233
234def print_file(infile, n=10):
235 # 打开文件并读取前10行
236 with open(infile, 'r') as file:
237 for i in range(n):
238 line = file.readline()
239 if line: # 检查是否还有行可读
240 print(line.strip())
241 else:
242 break # 如果文件行数少于10行,提前退出
243
244def count_lines(filename):
245 with open(filename, 'r', encoding='utf-8') as file:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected