49 lines
1.8 KiB
Python
49 lines
1.8 KiB
Python
import pandas as pd
|
|
|
|
from 爬虫.理财记账.ali_pay import ALiPay
|
|
from 爬虫.理财记账.zs_bank import ZsBank
|
|
|
|
# 显示所有列
|
|
pd.set_option('display.max_columns', None)
|
|
# 显示所有行
|
|
pd.set_option('display.max_rows', None)
|
|
# 输出不折行
|
|
pd.set_option('expand_frame_repr', False)
|
|
# 最大列宽度
|
|
pd.set_option('display.max_colwidth', None)
|
|
|
|
|
|
class BillHandle:
|
|
def __init__(self, ali_pay_file, zs_bank_file, sheet_name):
|
|
self.ali_pay_file, self.zs_bank_file, self.sheet_name = ali_pay_file, zs_bank_file, sheet_name
|
|
self.df = pd.DataFrame(
|
|
columns=['交易类型', '日期', '分类', '子分类', '账户1', '账户2', '金额', '成员', '商家', '项目', '备注'])
|
|
|
|
def __init_ali_bill(self):
|
|
ali_pay_data = ALiPay(self.ali_pay_file).get_ali_pay_bill()
|
|
ali_pay_data['交易类型'] = '支出'
|
|
ali_pay_data['日期'] = ali_pay_data['创建时间']
|
|
ali_pay_data['账户1'] = ali_pay_data['账户']
|
|
ali_pay_data['备注'] = ali_pay_data['商品名称'] + "_" + ali_pay_data['对方名称']
|
|
self.df = pd.concat([self.df, ali_pay_data])
|
|
|
|
def __init_zs_bank_bill(self):
|
|
zs_bank_data = ZsBank(self.zs_bank_file, self.sheet_name).get_zs_bank_bill()
|
|
zs_bank_data['交易类型'] = '支出'
|
|
zs_bank_data['账户1'] = '信用卡'
|
|
zs_bank_data['备注'] = zs_bank_data['来源'] + "_" + zs_bank_data['详情']
|
|
self.df = pd.concat([self.df, zs_bank_data])
|
|
|
|
def bill_opt(self):
|
|
self.__init_ali_bill()
|
|
self.__init_zs_bank_bill()
|
|
df = self.df
|
|
df = df.sort_values(by='日期', ascending=False).reset_index()
|
|
print(df)
|
|
|
|
if __name__ == '__main__':
|
|
ali_pay_file = '/Users/renmeng/Downloads/2088102231652088-20230918-108990157-买入交易.csv'
|
|
zs_bank_file = '/Users/renmeng/Downloads/招商银行对账单.xlsx'
|
|
zs_bank_sheet = '8-9月对账单'
|
|
BillHandle(ali_pay_file, zs_bank_file, zs_bank_sheet).bill_opt()
|