当前位置:网站首页>一、多个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()
边栏推荐
- Is flutter being quietly abandoned? On the future of flutter
- PyTorch基础知识(可入门)
- The differences and reasons between MySQL with and without quotation marks when querying string types
- 并发编程学习笔记 之 原子操作类AtomicInteger详解
- 第一周任务 深度学习和pytorch基础
- 【综述】图像分类网络
- MarkDown简明语法手册
- Semaphore (semaphore) for learning notes of concurrent programming
- [semantic segmentation] Introduction to mapillary dataset
- 【Transformer】ACMix:On the Integration of Self-Attention and Convolution
猜你喜欢
第三周周报 ResNet+ResNext
二、OCR训练时,将txt文件和图片数据转为lmdb文件格式
anaconda中移除旧环境、增加新环境、查看环境、安装库、清理缓存等操作命令
Yum local source production
Flutter正在被悄悄放弃?浅析Flutter的未来
神经网络相关知识回顾(PyTorch篇)
Ffmpeg creation GIF expression pack tutorial is coming! Say thank you, brother black fly?
mysql在查询字符串类型的时候带单引号和不带的区别和原因
备份谷歌或其他浏览器插件
【Transformer】AdaViT: Adaptive Vision Transformers for Efficient Image Recognition
随机推荐
Technology that deeply understands the principle of MMAP and makes big manufacturers love it
【Transformer】ATS: Adaptive Token Sampling For Efficient Vision Transformers
A preliminary study on fastjason's autotype
2021-06-10
【Transformer】AdaViT: Adaptive Tokens for Efficient Vision Transformer
[semantic segmentation] overview of semantic segmentation
Tear the ORM framework by hand (generic + annotation + reflection)
【综述】图像分类网络
Set automatic build in idea - change the code, and refresh the page without restarting the project
Interesting talk about performance optimization thread pool: is the more threads open, the better?
【语义分割】语义分割综述
神经网络相关知识回顾(PyTorch篇)
Anr Optimization: cause oom crash and corresponding solutions
[image classification] how to use mmclassification to train your classification model
[convolution kernel design] scaling up your kernels to 31x31: revising large kernel design in CNN
引入Spacy模块出错—OSError: [E941] Can‘t find model ‘en‘.
Configuration and use of Nacos external database
mysql在查询字符串类型的时候带单引号和不带的区别和原因
[semantic segmentation] setr_ Rethinking Semantic Segmentation from a Sequence-to-Sequence Perspective with Transformer
Operation commands in anaconda, such as removing old environment, adding new environment, viewing environment, installing library, cleaning cache, etc