在泰迪杯中,设计到了对excel文件进行处理,提取文件并且转换为YOLO格式,最后保存到txt中
1、excel文件样式
这儿主要是提取其中有信息的部分,没有虫子的部分剔除
2、代码:
import xlrd
import os
readFile=xlrd.open_workbook("D:\\学习\\泰迪杯\\正式数据\\附件2\\try.xls") #文件对象
sheetName=readFile.sheet_names()
sheetOne=readFile.sheet_by_index(0) #表对象
nRow=sheetOne.nrows #行数量
nCol=sheetOne.ncols #列数量
root_dir="D:\\学习\\泰迪杯\\正式数据\\附件2"
out_path="data1"
for i in range(nRow):
if int(sheetOne.row(i)[2].value)>0:
lable=str(sheetOne.row(i)[1].value).split(".jpg")[0]
object_class = sheetOne.row(i)[2].value
if object_class==10.0: #以下是为了与YOLOv