Author:Xuliu
Time:20211102
Fuction:-1 is trash file,we should delete the line of -1
Before Run:
After Run:
import os
import glob
import codecs
root_path = '/home/xpy/xl/workstation/Car/Dataset/Annotations'
save_path = '/home/xpy/xl/workstation/Car/Dataset/IDAnnotations1'
if not os.path.exists(save_path):
os.makedirs(save_path)
txt=os.listdir(root_path)
for i in txt:
f = codecs.open(os.path.join(root_path,i), mode='r', encoding='utf-8')
lines =f.readlines()
resf = open(os.path.join(save_path, i[:-4] + '.txt'), mode='wt')
for l in lines:
if '-1' not in l:
resf.write(l)
f.close()
resf.close()