TXT文件按条件批量删除行工具 v2.10下载

官方
  • 大小:15.07MB
  • 发布日期:2025年8月12日
  • 类别:文字编辑
  • 更新:2025-03-9 20:34:22
  • 版本:v13.60.0
  • 评分:★★★★☆
  • 需要网络无广告

软件信息

  • 软件名称TXT文件按条件批量删除行工具 v2.10下载
  • 支持语言简体中文
  • 授权方式免费软件
  • 更新日期2025年8月12日
  • 文件大小15.07MB
  • 下载文件名txtfileutilbyloker.zip

软件介绍

TXT文件按条件批量删除行工具软件

TXT文件按条件批量删除行工具是用Python语言写的非常多的人都在使用人用的一款文本处理软件,源码开放,界面简单易用,支持批量删除行含关键字或词的行、空行以及批量字符小于多少删除行,使用的时候只需要操作几个步骤即可进行转换,非常非常方便,效率高,减少不必要的时间浪费,欢迎下载使用。

TXT文件按条件批量删除行工具是用Python语言写的非常多的人都在使用人用的一款文本处理软件,源码开放,界面简单易用,支持批量删除行含关键字或词的行、空行以及批量字符小于多少删除行,使用的时候只需要操作几个步骤即可进行转换,非常非常方便,效率高,减少不必要的时间浪费,欢迎下载使用。

软件特色

批量删除行含关键字或词的行(多个关键字/词中间用空格隔开)

批量删除空行

批量字符小于多少(可设定)删除行

使用方法

点击打开文件批量选择TXT文件。

需要的功能前打勾,并配置。

点击【开始 】即可进行转换。

最后会生成原文件名+_new.txt的文件。

源码一览

import os

import tkinter

from tkinter import ttk, filedialog, messagebox # 有Combobox、LabelFrame 组件时需要本语句

FilePaths = ()

def getTxtFiles():

global FilePaths

files = filedialog.askopenfilenames(filetypes=[('text files', '.txt')])

if files:

FilePaths = files

# print(FilePaths)

for f_name in files:

ctrl_FileListBox.insert('end', f_name)

ctrl_FileListBox.insert(tkinter.INSERT, '⁄n')

else:

messagebox.showinfo(title='提示', message='没有选择任何文件!')

def KeyWordScan(keys, s):

key_words = keys.split(" ")

t_f = False

for key_word in key_words:

if key_word in s:

t_f = True

return t_f

def ctrl_StartBtn_clicked():

has_key_words = int_CheckBox1.get()

key_words = str_KeyWord.get()

has_empty_line = int_CheckBox2.get()

has_N = int_CheckBox3.get()

n = str_KeyNum.get()

for file in FilePaths: # 循环遍历文件

s_file = open(os.path.splitext(file)[0]+"_new"+os.path.splitext(file)[1], 'w+') # 文件保存位置

f_lines = open(file, encoding='utf8').readlines() # 打开文件,读入每一行

for s in f_lines: # s: 每一行的内容

# 操作1

if has_key_words:

if KeyWordScan(key_words, s):

continue

# 操作2

if has_empty_line:

if len(s.strip()) == 0:

continue

# 操作3:

if has_N:

if len(s.strip()) < int(n):

continue

s_file.write(s)

s_file.close() # 关闭文件

root = tkinter.Tk() # 设定窗体变量

root.geometry('450x300') # 格式('宽x高+x+y')其中x、y为位置

root.title('TxT文件处理助手V0.1 By 52poje Loker')

ctrl_Frame1 = ttk.LabelFrame(root, text='选项')

ctrl_Frame1.place(x=14, y=72, width=388, height=101)

ctrl_StartBtn = tkinter.Button(root, text='确定', font=('宋体', '9'),

command=ctrl_StartBtn_clicked) # 可在括号内加上调用函数部分 ,command=ctrl_StartBtn_clicked

ctrl_StartBtn.place(x=22, y=223, width=72, height=29)

ctrl_QuitBtn = tkinter.Button(root, text='取消', font=('宋体', '9')) # 可在括号内加上调用函数部分 ,command=ctrl_QuitBtn_clicked

ctrl_QuitBtn.place(x=108, y=223, width=72, height=29)

ctrl_FileListBox = tkinter.Text(root, font=('宋体', '9'))

ctrl_FileListBox.place(x=14, y=7, width=260, height=38)

ctrl_Scrollbar1 = tkinter.Scrollbar(root, command=ctrl_FileListBox.xview, orient=tkinter.HORIZONTAL)

ctrl_Scrollbar1.place(x=14, y=46, width=261, height=16)

ctrl_Scrollbar2 = tkinter.Scrollbar(root, command=ctrl_FileListBox.yview, orient=tkinter.VERTICAL)

ctrl_Scrollbar2.place(x=275, y=7, width=16, height=39)

ctrl_FileListBox.config(xscrollcommand=ctrl_Scrollbar1.set, yscrollcommand=ctrl_Scrollbar2.set, wrap='none')

int_CheckBox1 = tkinter.IntVar() # 绑定变量

ctrl_CheckBox1 = tkinter.Checkbutton(ctrl_Frame1, text='删除行含关键字或词的行', variable=int_CheckBox1, font=('宋体', '9'))

ctrl_CheckBox1.place(x=14, y=14, height=22) # 考虑到对齐问题,不列入宽度,需要时手动加入 width=130

ctrl_CheckBox1.deselect() # 默认为未选中状态

Ctrl_Label1 = tkinter.Label(ctrl_Frame1, text="关键字:")

Ctrl_Label1.place(x=180, y=14, width=55, height=22)

str_KeyWord = tkinter.StringVar() # 绑定变量

ctrl_KeyWord = tkinter.Entry(ctrl_Frame1, textvariable=str_KeyWord, font=('宋体', '9'))

ctrl_KeyWord.place(x=230, y=14, width=150, height=22)

int_CheckBox2 = tkinter.IntVar() # 绑定变量

ctrl_CheckBox2 = tkinter.Checkbutton(ctrl_Frame1, text='删除空行', variable=int_CheckBox2, font=('宋体', '9'))

ctrl_CheckBox2.place(x=14, y=36, height=22) # 考虑到对齐问题,不列入宽度,需要时手动加入 width=130

ctrl_CheckBox2.deselect() # 默认为未选中状态

int_CheckBox3 = tkinter.IntVar() # 绑定变量

ctrl_CheckBox3 = tkinter.Checkbutton(ctrl_Frame1, text='删除字符小于N的行', variable=int_CheckBox3, font=('宋体', '9'))

ctrl_CheckBox3.place(x=14, y=58, height=22) # 考虑到对齐问题,不列入宽度,需要时手动加入 width=130

ctrl_CheckBox3.deselect() # 默认为未选中状态

Ctrl_Label = tkinter.Label(ctrl_Frame1, text="N =")

Ctrl_Label.place(x=220, y=58, width=22, height=22)

str_KeyNum = tkinter.StringVar() # 绑定变量

ctrl_KeyNum = tkinter.Entry(ctrl_Frame1, textvariable=str_KeyNum, font=('宋体', '9'))

ctrl_KeyNum.place(x=250, y=58, width=22, height=22)

ctrl_OpenFileBtn = tkinter.Button(root, text='选择文件',

font=('宋体', '9'),

command=getTxtFiles) # 可在括号内加上调用函数部分 ,command=ctrl_OpenFileBtn_clicked

ctrl_OpenFileBtn.place(x=305, y=18, width=72, height=29)

# str_OutputPath = tkinter.StringVar() # 绑定变量

# ctrl_OutputPath = tkinter.Entry(root, textvariable=str_OutputPath, font=('宋体', '9'))

# ctrl_OutputPath.place(x=14, y=187, width=209, height=22)

root.mainloop()

软件测评

按照用户需求进行TXT文件处理

能实现指定行批量删除功能

提高了工作效率

以上就是非凡软件站小编今日为大家带来的TXT文件按条件批量删除行工具,更多软件下载尽在非凡软件站

下载帮助:点击TXT文件按条件批量删除行工具软件立即下载,解压后安装,一直点下一步,直到安装完成,再打开使用。

软件截图

TXT文件按条件批量删除行工具 v2.10

版权声明

TXT文件按条件批量删除行工具软件所展示的资源内容均来自于第三方用户上传分享,您所下载的资源内容仅供个人学习交流使用,严禁用于商业用途,软件的著作权归原作者所有,如果有侵犯您的权利,请来信告知,我们将及时撤销。

收起内容