当前位置:网站首页>一、多个txt文件合并成1个txt文件
一、多个txt文件合并成1个txt文件
2022-07-29 05:22:00 【MY头发乱了】
项目场景:
主要完成OCR训练前,dataset需要加载的lmdb格式的文件。
问题描述:
直接上代码,一看就明白:
#@Override
import os
def Combine_txt():
dirpath = r"E:\enducate\test_paper\Train_code\txt1111"
files = os.listdir(dirpath)
res = ""
for file in files:
if file.endswith(".txt"):
name = file[:-3] + "png"
img_path = os.path.join(dirpath, name)
txtpath = os.path.join(dirpath, file)
with open(txtpath, "r", encoding="utf-8") as file:
content = file.read()
text = img_path + "\t" + content
file.close()
input = "%s\n" % (text)
res += input
outpath = r'E:\enducate\test_paper\Train_code\output.txt'
with open(outpath, "a", encoding="utf-8") as outfile:
outfile.write(res)
outfile.close()
print(len(res))
if __name__ == '__main__':
Combine_txt()
边栏推荐
- 【Transformer】AdaViT: Adaptive Tokens for Efficient Vision Transformer
- 四、One-hot和损失函数的应用
- The third week of postgraduate freshman training: resnet+resnext
- 深入理解MMAP原理,让大厂都爱不释手的技术
- Transformer回顾+理解
- Ribbon learning notes II
- 【Transformer】AdaViT: Adaptive Tokens for Efficient Vision Transformer
- Spring, summer, autumn and winter with Miss Zhang (3)
- ASM插桩:学完ASM Tree api,再也不用怕hook了
- C connect to SharePoint online webservice
猜你喜欢

GAN:生成对抗网络 Generative Adversarial Networks

Ffmpeg creation GIF expression pack tutorial is coming! Say thank you, brother black fly?

虚假新闻检测论文阅读(五):A Semi-supervised Learning Method for Fake News Detection in Social Media

Spring, summer, autumn and winter with Miss Zhang (2)

虚假新闻检测论文阅读(二):Semi-Supervised Learning and Graph Neural Networks for Fake News Detection

mysql 的show profiles 使用。

Reporting Services- Web Service

Flutter 绘制技巧探索:一起画箭头(技巧拓展)

pip安装后仍有解决ImportError: No module named XX

C # judge whether the user accesses by mobile phone or computer
随机推荐
ASM piling: after learning ASM tree API, you don't have to be afraid of hook anymore
【目标检测】KL-Loss:Bounding Box Regression with Uncertainty for Accurate Object Detection
Flink connector Oracle CDC synchronizes data to MySQL in real time (oracle12c)
Detailed explanation of MySQL statistical function count
Configuration and use of Nacos external database
isAccessible()方法:使用反射技巧让你的性能提升数倍
性能优化之趣谈线程池:线程开的越多就越好吗?
Ribbon learning notes 1
第三周周报 ResNet+ResNext
Tear the ORM framework by hand (generic + annotation + reflection)
The difference between asyncawait and promise
[DL] build convolutional neural network for regression prediction (detailed tutorial of data + code)
Valuable blog and personal experience collection (continuous update)
mysql在查询字符串类型的时候带单引号和不带的区别和原因
ANR优化:导致 OOM 崩溃及相对应的解决方案
clion+opencv+aruco+cmake配置
【DL】关于tensor(张量)的介绍和理解
Briefly talk about the difference between pendingintent and intent
mysql插入百万数据(使用函数和存储过程)
Reporting Services- Web Service