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.
 
 
 

36 lines
1.1 KiB

import os
import sys
# 重定向输出
log_file = open(r'D:\java\project\debug_log.txt', 'w', encoding='utf-8')
original_stdout = sys.stdout
sys.stdout = log_file
print("开始调试...")
print(f"当前目录: {os.getcwd()}")
try:
import pandas as pd
print("pandas导入成功")
input_file = r'D:\计量经济学\计量实验资料及作业要求\计量实验资料及作业要求\图文帖子实验数据(新).xlsx'
print(f"输入文件: {input_file}")
print(f"文件存在: {os.path.exists(input_file)}")
if os.path.exists(input_file):
print(f"文件大小: {os.path.getsize(input_file) / 1024:.2f} KB")
print("开始读取...")
df = pd.read_excel(input_file, engine='openpyxl')
print(f"读取成功: {len(df)}")
print(f"列数: {len(df.columns)}")
print(f"前5列: {list(df.columns)[:5]}")
except Exception as e:
print(f"错误: {e}")
import traceback
traceback.print_exc()
print("调试结束")
sys.stdout = original_stdout
log_file.close()
print("日志已保存")