51 lines
1.5 KiB
Python
51 lines
1.5 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
简单检查fast_results.pkl文件的结构
|
|
"""
|
|
|
|
import pickle
|
|
import sys
|
|
|
|
def check_file(results_file):
|
|
try:
|
|
print(f"检查文件: {results_file}")
|
|
|
|
# 只读取文件头,不完全加载
|
|
with open(results_file, 'rb') as f:
|
|
# 尝试读取文件大小
|
|
f.seek(0, 2) # 移到文件末尾
|
|
file_size = f.tell()
|
|
print(f"文件大小: {file_size / (1024**3):.2f} GB")
|
|
|
|
# 回到文件开头
|
|
f.seek(0)
|
|
|
|
# 尝试读取pickle头
|
|
try:
|
|
# 使用最高协议读取
|
|
results = pickle.load(f)
|
|
print(f"数据类型: {type(results)}")
|
|
|
|
if isinstance(results, list):
|
|
print(f"列表长度: {len(results)}")
|
|
if len(results) > 0:
|
|
first_item = results[0]
|
|
print(f"第一个元素类型: {type(first_item)}")
|
|
if isinstance(first_item, dict):
|
|
print(f"字典键: {list(first_item.keys())}")
|
|
elif isinstance(results, dict):
|
|
print(f"字典键: {list(results.keys())}")
|
|
|
|
except Exception as e:
|
|
print(f"Pickle读取错误: {e}")
|
|
|
|
except Exception as e:
|
|
print(f"文件操作错误: {e}")
|
|
|
|
if __name__ == "__main__":
|
|
if len(sys.argv) != 2:
|
|
print("用法: python CHECK_RESULTS.py <results_file>")
|
|
sys.exit(1)
|
|
|
|
check_file(sys.argv[1])
|