| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- import pandas as pd
- from tkinter import messagebox
- from flow_parser_base import FlowParserBase
- class NongxinFlowParser(FlowParserBase):
- """农信银行流水解析器"""
-
- def parse(self, flow_file_path):
- """解析农信银行流水文件,返回标准化的流水数据"""
- try:
- flow_df = pd.read_excel(flow_file_path, header=None)
-
- flow_data = []
-
- for idx, row in flow_df.iterrows():
- if idx < 3:
- continue
-
- if pd.isna(row[0]) or str(row[0]).strip() == '':
- continue
-
- try:
- date_part = str(row[0]).strip()
- time_part = str(row[1]).strip()
- transaction_time = f"{date_part} {time_part}"
-
- shouzhi_type = str(row[2]).strip()
-
- income_amount = pd.to_numeric(str(row[3]).replace(',', '') if not pd.isna(row[3]) else '0', errors='coerce')
- expense_amount = pd.to_numeric(str(row[4]).replace(',', '') if not pd.isna(row[4]) else '0', errors='coerce')
-
- if pd.isna(income_amount):
- income_amount = 0
- if pd.isna(expense_amount):
- expense_amount = 0
-
- balance = str(row[5]).strip() if not pd.isna(row[5]) else ''
- opponent_name = str(row[6]).strip() if not pd.isna(row[6]) else ''
- opponent_bank = str(row[8]).strip() if not pd.isna(row[8]) else ''
- summary = str(row[9]).strip() if not pd.isna(row[9]) else ''
-
- if income_amount > 0 or expense_amount > 0:
- flow_data.append({
- "交易时间": transaction_time,
- "对方户名": opponent_name,
- "摘要": summary,
- "收入": income_amount,
- "支出": expense_amount,
- "余额": balance
- })
- except Exception as e:
- continue
-
- if not flow_data:
- messagebox.showerror("错误", "农信银行流水解析失败:未找到有效数据")
- return None
-
- standard_flow = pd.DataFrame(flow_data)
-
- return standard_flow
- except Exception as e:
- messagebox.showerror("错误", f"解析农信银行流水失败:{str(e)}")
- return None
-
- def get_bank_name(self):
- """返回银行名称"""
- return "农信银行"
|