1. 文件路径设定及文件遍历
import os
path = 'E:\\Python36\\testdata'
os.chdir(path)
os.listdir()
for filename in os.listdir():
file = open(filename, 'r')
for eachline in file.readlines():
# process eachline
2. 提取glass ID
IDlist = []
file = open('A1770266172.txt', 'r')
for line in file.readlines():
if line.startswith('Process'):
ID = line[37: ]
IDlist.append(ID)
print(IDlist)
3. 提取Input/Buffer/Inspection/Printer/UvLevel/Output时间
for line in file.readlines():
if line.startswith('Arrived at Input'):
InputIN = line[20:39]
elif line.startswith('Departed at Input'):
InputOUT = line[18:37]
elif line.startswith('Arrived at Buffer'):
BufferSLOT = line[17:18]
BufferIN = line[22:41]
elif line.startswith('Departed at Buffer'):
BufferOUT = line[20:39]
elif line.startswith('Arrived at Inspection'):
InspectionIN = line[25: ]
elif line.startswith('Departed at Inspection'):
InspectionOUT = line[23:42]
elif line.startswith('Arrived at Printer'):