python-suspense

import time

import pandas as pd
import openpyxl
import openpyxl.cell._writer
import os
from tkinter.filedialog import *
from tqdm import *

input('请在此处回车开始运行程序')

print('需要转化为Excel格式的txt/rtz类型文件')

files = askopenfilenames(title= '请选择需要转化的txt/rtz文件')

for i in files:

根据是否存在借贷按照右侧基准补齐

def debt_credit(list_input: list, length: int):
if ('借' in list_input) | ('贷' in list_input):
while len(list_input) < length:
list_input.insert(0, '')
return list_input

去除空格后补长度

def remove_space(list_input, length)

转换主程序

def transfer(file):
# 测算最长行
max_line = max([len(i) for i in open(file, 'r')])
print(max_line)
# 进行循环
with open(file, 'r') as f:
for index, line in tqdm(enumerate(f), total=sum([1 for i in open(file, 'r')])):
content = line.split()

transfer(r"D:\Desktop\新建文件夹\新建文件夹\待抵扣初处理 - 副本 (4).txt")

print(debt_credit(['借', 1, 1, 1], 5))

posted @ 2024-06-10 21:01  AZ26  阅读(64)  评论(0)    收藏  举报