You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
929 B
26 lines
929 B
import ijson
|
|
import os
|
|
|
|
from Tools.KG_Config import TOPIC
|
|
|
|
# 文件路径
|
|
file_path = rf"d:\dsWork\dsProject\dsLightRag\Topic\{TOPIC}\vdb_chunks.json"
|
|
|
|
# 检查文件是否存在
|
|
if not os.path.exists(file_path):
|
|
raise FileNotFoundError(f"文件不存在: {file_path}")
|
|
|
|
# 使用ijson流式读取JSON文件
|
|
with open(file_path, 'r', encoding='utf-8') as f:
|
|
# 流式迭代所有块
|
|
chunks = ijson.items(f, 'data.item')
|
|
chunk_list = list(chunks)
|
|
print(f"共找到 {len(chunk_list)} 个块:")
|
|
for i, chunk in enumerate(chunk_list, 1):
|
|
print(f"块 {i}:")
|
|
print(f"ID: {chunk.get('__id__')}")
|
|
print(f"创建时间: {chunk.get('__created_at__')}")
|
|
print(f"文档ID: {chunk.get('full_doc_id')}")
|
|
print(f"文件路径: {chunk.get('file_path')}")
|
|
print(f"内容预览: {chunk.get('content', '')}") # 显示前100字符
|
|
print("---") |