| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- import pandas as pd
- from tkinter import messagebox
- from flow_parser_base import FlowParserBase
- class CCBFlowParser(FlowParserBase):
- """建设银行流水解析器"""
-
- def parse(self, flow_file_path):
- """解析建行流水文件,返回标准化的流水数据"""
- try:
- flow_df = pd.read_excel(flow_file_path, dtype=str)
-
- flow_df.columns = flow_df.columns.str.strip()
-
- required_columns = ["交易时间", "对方户名", "摘要", "贷方发生额(收入)", "借方发生额(支取)", "对方开户机构", "备注", "余额"]
-
- missing_fields = [k for k in required_columns if k not in flow_df.columns]
- if missing_fields:
- messagebox.showerror("错误", f"建行流水缺少必要列:{missing_fields}")
- return None
-
- standard_flow = flow_df[required_columns].copy()
- standard_flow = standard_flow.rename(columns={
- "贷方发生额(收入)": "收入",
- "借方发生额(支取)": "支出"
- })
-
- standard_flow["收入"] = pd.to_numeric(standard_flow["收入"], errors='coerce').fillna(0)
- standard_flow["支出"] = pd.to_numeric(standard_flow["支出"], errors='coerce').fillna(0)
-
- return standard_flow
- except Exception as e:
- messagebox.showerror("错误", f"解析建行流水失败:{str(e)}")
- return None
-
- def get_bank_name(self):
- """返回银行名称"""
- return "建设银行"
|