refactor: 重构文件读取和日志处理以提升性能和稳定性
- 新增 smart_read_excel 工具函数,统一 Excel 读取逻辑并自动选择引擎 - 重构 ConfigManager.get_path 方法,使用 pathlib 提升路径处理可靠性 - 将 GUI 日志处理改为异步队列模式,避免 UI 阻塞 - 优化 ExcelProcessor 的表头识别逻辑,避免重复读取文件 - 更新配置文件中的版本号
This commit is contained in:
@@ -708,14 +708,18 @@ class ExcelProcessor:
|
||||
|
||||
logger.info(f"识别到表头在第 {header_row+1} 行")
|
||||
|
||||
# 重新读取Excel,正确指定表头行
|
||||
# 重新设置表头,避免二次读取
|
||||
if progress_cb:
|
||||
try:
|
||||
progress_cb(94)
|
||||
except Exception:
|
||||
pass
|
||||
df = pd.read_excel(file_path, header=header_row)
|
||||
logger.info(f"使用表头行重新读取数据,共 {len(df)} 行有效数据")
|
||||
|
||||
# 使用识别到的表头行设置列名,并过滤掉表头之前的行
|
||||
df.columns = df.iloc[header_row]
|
||||
df = df.iloc[header_row + 1:].reset_index(drop=True)
|
||||
|
||||
logger.info(f"重新整理数据结构,共 {len(df)} 行有效数据")
|
||||
|
||||
# 提取商品信息
|
||||
if progress_cb:
|
||||
|
||||
Reference in New Issue
Block a user