Python Excel 批量付款导入明细数据分析整理 核销下载表导入数据转换
批量付款导入明细数据分析整理 核销下载表导入数据转换
# 批量付款导入明细整理
def payTransform():
if os.path.exists(".\\1.xls"):
replace_excel(".", "1.xls")
os.unlink("1.xls")
file_path = ".\\1.xlsx"
total_list = readFromExcel(file_path)
os.unlink(file_path)
print("成功读取{}条数据".format(len(total_list)))
print("--------批量付款明细格式转换--------\n")
# new_list = plProcessDo(total_list)
print("输入:1 ----(1.xls)\n 2 ----(1.xlsx)\n")
type = input("请输入要转换的原始表:")
if type == "1":
new_list = payTransDo(total_list)
if type == "2":
new_list = payTransDo(total_list, 1)
writeToExcel(".\\payTransOk.xlsx", new_list)
# 核销下载表导入数据转换
def jWOTransDo(t, type=0):
new_list = []
n = 0
# 序号 编号 下载凭证号 运单号 发货人 收货人 操作时间 核销单位 核销项目 来源 类别 方向 交易日期 核销上级科目 核销科目 摘要 收入 支出 结余 分公司 网点 经办人 收据号码 支票号码 发票号码 手工凭证号 反核销金额 反核销经办人 反核销日期
new_list.append(
["主键", "序号", "编号", "下载凭证号", "运单号", "发货人", "收货人", "操作时间", "核销单位", "核销项目", "来源", "类别", "方向", "交易日期", "核销上级科目",
"核销科目", "摘要", "收入", "支出", "结余", "分公司", "网点", "经办人", "收据号码", "支票号码", "发票号码", "手工凭证号", "反核销金额", "反核销经办人",
"反核销日期"])
if type == 0 and t[0][1] != "审核人":
print("表格格式不正确!请查证!只能使用系统导出的格式!")
return
# 去掉表头
# t = t[1:]
# 0 代表
if type == 0:
site, companyName = "W-北京兴州通", ""
for i in range(len(t)):
if not (t[i][3]): continue
nt = []
n = n + 1
# 主键 "{20200720}{W-北京兴州通}{}核销下载导入".format()
cellDate = t[i][24].strftime('%Y%m%d')
if t[i][24]:
nt.append("{}{}{}核销下载导入".format(cellDate, site, companyName))
# nt.append("") # 主键
nt.append(n) # 序号
nt.append(t[i][3]) # 编号
nt.append(t[i][4]) # 下载凭证号
nt.append(t[i][29]) # 运单号
nt.append(t[i][35]) # 发货人
nt.append(t[i][36]) # 收货人
nt.append(t[i][24]) # 操作时间
# 收入存在时 核销单位=发货人
if t[i][14]:
nt.append(t[i][35]) # 核销单位
else:
nt.append("")
nt.append(t[i][30]) # 核销项目
nt.append(t[i][5]) # 来源
nt.append(t[i][6]) # 类别
nt.append(t[i][7]) # 方向
nt.append(t[i][8]) # 交易日期
nt.append(t[i][9]) # 核销上级科目
nt.append(t[i][10]) # 核销科目
nt.append(t[i][13]) # 摘要
nt.append(t[i][14]) # 收入
nt.append(t[i][15]) # 支出
nt.append(t[i][16]) # 结余
nt.append(t[i][17]) # 分公司
nt.append(t[i][18]) # 网点
nt.append(t[i][19]) # 经办人
nt.append(t[i][20]) # 收据号码
nt.append(t[i][21]) # 支票号码
nt.append(t[i][22]) # 发票号码
nt.append(t[i][23]) # 手工凭证号
nt.append(t[i][31]) # 反核销金额
nt.append(t[i][32]) # 反核销经办人
nt.append(t[i][33]) # 反核销日期
new_list.append(nt)
# 1 代表
if type == 1:
for i in range(len(t)):
if not (t[i][1]): continue
nt = []
n = n + 1
nt.append("") # 单号
nt.append(n) # 序号
nt.append(t[i][3]) # 运单号
nt.append(t[i][9]) # 账款单位
nt.append("") # 对账项目
nt.append("") # 客户项目
nt.append("") # 对方单号
nt.append("收入送货费") # 计费项目
nt.append("") # 计费单位
nt.append("") # 计费单价
nt.append("") # 计费数量
nt.append("") # 最低收费
nt.append("") # 备注
nt.append("") # 借方金额
nt.append(t[i][93]) # 贷方金额 收入
nt.append("") # 金额验证
nt.append("") # 对应表金额
if t[i][8]:
nt.append(t[i][8]) # 到站
else:
nt.append(t[i][7])
nt.append(t[i][5]) # 日期
new_list.append(nt)
return new_list
# 核销下载表导入明细整理
def journalWriteOff():
if os.path.exists(".\\1.xls"):
replace_excel(".", "1.xls")
os.unlink("1.xls")
file_path = ".\\1.xlsx"
total_list = readFromExcel(file_path)
os.unlink(file_path)
print("成功读取{}条数据".format(len(total_list)))
print("--------核销下载表明细格式转换--------\n")
print("输入:1 ----(1.xls)\n 2 ----(1.xlsx)\n")
type = input("请输入要转换的原始表:")
if type == "1":
new_list = jWOTransDo(total_list)
if type == "2":
new_list = jWOTransDo(total_list, 1)
writeToExcel(".\\jWOTransOk.xlsx", new_list)