利用python提取txt并且抓取有用信息到excel

更新时间:2023-07-29 15:23:14 阅读: 评论:0

玛咖片的功效与作用利⽤python提取txt并且抓取有⽤信息到excel
import xlwt
import os
from os import path
import random
text_condition=("C1","C2","C3","C4")
bin_kind=("0",)
ply_name=("bridge_1mm","double_T_ction_1mm","interction1_1mm","interction2_1mm","straight_road_1mm","T_ction_1mm") workpath=path.dirname(__file__)
Text_paths=[]
for i in range(4):
Text_paths.append(workpath+"\\"+text_condition[i]+"\\"+"Text")
梦到画画
def readTxt_list(lines):
value_list=[]
attribute=[0for n in range(16)]
recyle_time=True
for all_line in lines:
line=all_line.split()
if len(line)>=2:
if line[0]=="All"and line[1]=="frames":
if len(line)>=5and line[5]=="points:":
attribute[0]=int(line[6])
if line[2]=="geometry"and line[3]=="bits:":心梗是什么症状
attribute[2]=int(line[4])
if line[2]=="attributes"and line[3]=="bits:":
attribute[3]=int(line[4])
if line[2]=="total"and line[4]=="size:":
attribute[1]=int(line[5])
if line[2]=="total"and line[5]=="(ur):":
if  recyle_time==True:
attribute[14]=float(line[6])
recyle_time=Fal
el:
attribute[15]=float(line[6])
recyle_time=True
if line[2]=="MD5"and line[4]=="status:":
value_list.append(attribute)
attribute=["0"for n in range(16)]
elif line[0]=="D1_PSNR_Ave":
attribute[4]=float(line[2])
elif line[0]=="D1_HausdorffPSNR":
attribute[9]=float(line[2])
elif line[0]=="c[0]_PSNR_Ave":
attribute[5]=float(line[2])
elif line[0]=="c[0]_HausdorffPSNR_Ave":
attribute[10]=float(line[2])
清理系统垃圾
elif line[0]=="c[1]_PSNR_Ave":
attribute[6]=float(line[2])
elif line[0]=="c[1]_HausdorffPSNR_Ave":
attribute[11]=float(line[2])
elif line[0]=="c[2]_PSNR_Ave":
attribute[7]=float(line[2])
elif line[0]=="c[2]_HausdorffPSNR_Ave":
attribute[12]=float(line[2])
elif line[0]=="rel_PSNR_Ave":
attribute[8]=float(line[2])
elif line[0]=="rel_HausdroffPSNR_Ave":
attribute[13]=float(line[2])
return value_list
def text_to_excel(sheet,attribute_list,tile_infor,excel_name,row,ply_name,xls,output_name):
sheet.write(row,0,ply_name)
for list_data in attribute_list:
妈妈的朋友西瓜视频
14寸电脑多大column=1
for data in list_data:
sheet.write(row,column,data)
column+=1
row+=1
def read_txt(text_condition,output_name):
xls=xlwt.Workbook(encoding="ANSI")
for condition in text_condition:
sheet=xls.add_sheet(condition)
tile_infor=["points","Total","geometry","attributes","D1_PSNR",\
"Y_PSNR","U_PSNR","V_PSNR","R_PSNR","D1_Haus",\
"Y_Haus","U_Haus","V_Haus","R_Haus",\
"encoder_time","decoder_time"]企业文化设计
ls=1
for head in tile_infor:
sheet.write(0,ls,head)
ls+=1
row=1
for name in ply_name:
for B in bin_kind:
_dir=workpath+"\\"+condition+"\\"+"Text"+"\\"
鱼翅捞饭if ists(_dir+"\\"+name+"_"+B+".txt"):
file_txt=open(_dir+"\\"+name+"_"+B+".txt",'r')
value_list=[]
lines=adlines()
value_list=readTxt_list(lines)
##text_to_excel(sheet,value_list,tile_infor,name+"_"+B,row,name,xls,output_name)                    sheet.write(row,0,name+"_"+B)
for list_data in value_list:
column=1
for data in list_data:
sheet.write(row,column,data)
column+=1
row+=1
xls.save(workpath+"\\"+output_name+".xls")
read_txt(text_condition,"result")

本文发布于:2023-07-29 15:23:14,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/82/1122790.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:作用   抓取   提取   视频
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图