IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> Python知识库 -> python read dir files and find key words -> 正文阅读

[Python知识库]python read dir files and find key words

#!/usr/bin/env python

coding:utf-8

import os
import re

filelist=[]
#path = “/Volumes/C/work/veridian/issue/SMP_LAN_DOE/8-3A/”
#path = “/Volumes/C/work/veridian/SPC_calibration/data/”
path = “/Volumes/C/work/6x/issue/cc_acc/nvt_oqc_repeatdata/”
dict = {}
unitID = []
temperature = []
ggTemperature = []
passfail = []
flow = “”
unitID1 = 0
temperature1 = 0
ggTemperature1 = 0
testTime = 0
testflag = “”
filesummay = open(‘issue_report.txt’, ‘w’)
filesummay.write(‘carrierID’)
filesummay.write(’\t’)
filesummay.write(‘SN’)
filesummay.write(’\t’)
filesummay.write(str(‘gg_cc_dsg’))
filesummay.write(’\t’)
filesummay.write(str(‘tester_cc_dsg’))
filesummay.write(’\t’)
filesummay.write(‘test current’)
filesummay.write(’\t’)
filesummay.write(‘gg current’)
filesummay.write(’\t’)
filesummay.write(‘file’)
filesummay.write(’\n’)
errCode = ‘’

for root, dirs, files in os.walk(path):
for name in files:
#print(dir, name)
if name.endswith(".log"):
f=open(os.path.join(root,name),‘r’, encoding=‘gbk’)
filename=(os.path.join(root, name))
#print(filename)
data=f.read()
else:
continue # skip this file
testflag = “Pass”
# temperature1=0
# temperature1=0
# match = re.search(“created unit [ ([A-Z0-9]+) ]”, data, re.MULTILINE)
# if match:
# unitID.append(match.group(1))
# unitID1= match.group(1)
# else:
# unitID1=""
match = re.search(r"tester ID : [ ([A-Z0-9]+) ]", data, re.MULTILINE)
if match:
unitID.append(match.group(1))
unitID1 = match.group(1)
# print(unitID1)
else:
unitID1 = “”
‘’’ flowID
match = re.search(r"flow is:[ (\d+) ]", data, re.MULTILINE)
if match:
# unitID.append(match.group(1))
flow = match.group(1)
#print(flow)
else:
flow = “”
# Voltage b = [
‘’’
# Serial Number
match = re.search(r"Serial Number =(\w+)", data, re.MULTILINE)
if match:
# unitID.append(match.group(1))
SerialNo = match.group(1)
# print(SerialNo)
else:
SerialNo = “”

    # Voltage b = [

#1s gg current = [ -0.500175 ]A
match = re.search(r"1s gg current = [ (-\d+.\d+) ]", data, re.MULTILINE)
if match:
# temperature.append(match.group(1))
dsg_gg = match.group(1)
print(dsg_gg)
else:
dsg_gg = ‘’
# tester read current
match = re.search(
r"tester read curent = [ ((-)?\d+.\d+)",
data,
re.MULTILINE)
if match:
ggTemperature1 = match.group(1)
# ggTemperature.append(match.group(1))
# ggTemperature1 = match.group(2)
else:
ggTemperature1 = ‘’
match = re.search(r"tester read curent = [ ((-)?\d+.\d+)", data, re.MULTILINE)
#match = re.search(r"tester cell voltage = [ ((-)?\d+.\d+)", data, re.MULTILINE)
if match:
# passfail.append(match.group(0))
test_cell = match.group(1)
print(test_cell)
# match = re.search(r"test key [(\w+)",data, re.MULTILINE)
#test_cell = match.group(1)
#print(errCode)
else:
test_cell=""
#match = re.search(r"oqc_ocv_shipping ] | Lower spec [ 0.000000 ] | measurement [ ((-)?\d+.\d+)", data, re.MULTILINE)
match = re.search(r"1s gg current = [ (-\d+.\d+)", data, re.MULTILINE)
if match:
#test_cell = match.group(1)
#print(test_cell)
# passfail.append(match.group(0))
#testflag = “Error”
# match = re.search(r"test key [(\w+)",data, re.MULTILINE)
test_pack = match.group(1)
# print(test_pack)
else:
test_pack=""

    filesummay.write(str(unitID1))
    filesummay.write('\t')
    filesummay.write(str(flow))
    filesummay.write('\t')
    filesummay.write(str(dsg_gg))
    filesummay.write('\t')
    filesummay.write(str(ggTemperature1))
    filesummay.write('\t')
    filesummay.write(test_cell)
    filesummay.write('\t')
    filesummay.write(test_pack)
    filesummay.write('\t')
    filesummay.write(filename)
    filesummay.write('\n')
    errCode = ''

filesummay.close()

  Python知识库 最新文章
Python中String模块
【Python】 14-CVS文件操作
python的panda库读写文件
使用Nordic的nrf52840实现蓝牙DFU过程
【Python学习记录】numpy数组用法整理
Python学习笔记
python字符串和列表
python如何从txt文件中解析出有效的数据
Python编程从入门到实践自学/3.1-3.2
python变量
上一篇文章      下一篇文章      查看所有文章
加:2021-08-02 10:46:25  更:2021-08-02 10:48:55 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年5日历 -2024/5/6 22:31:45-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码