• opdriver 数据处理


     -n -c -h -w -k -................
    
    • 1
    import re
    import openpyxl
    
    Outfile = r'C:\Users\李召阳\Desktop\maskrcnn\test.txt'
    xlsx_Name = r"C:\Users\李召阳\Desktop\maskrcnn\test" + ".xlsx"
    
    
    
    
    list_all = ['n','c','H','W','k','y','x','p','q','u','v','i','j','g','F']
    str_all = ["-n(.*)-c","-c(.*)-H","-H(.*)-W","-W(.*)-k","-k(.*)-y","-y(.*)-x","-x(.*)-p","-p(.*)-q","-q(.*)-u","-u(.*)-v","-v(.*)-l","-l(.*)-j","-j(.*)-m","-g(.*)-F","-F(.*)-t"]
    father_list = []
    for i in range(len(list_all)):
        father_list.append([])
    
    
    
    
    def write_to_list(str,content,list):
        str = str
        num = len(list_all)
        for i in range(num):
            match = re.search(str[i],content)
    
    
            value = match.group(1)
            value = int(value)
            list[i].append(value)
        return list
    
    
    with open(Outfile, 'r') as f:
        for line in f:
            f = str(line)
    
            list_n = write_to_list(str_all,f,father_list)
        print(father_list)
    
    
    xls = openpyxl.Workbook()
    sheet = xls.get_sheet_by_name('Sheet')
    
    
    
    for i in range(len(list_all)):
    
        val = list_all[i]
    
        sheet.cell(row=1,column=i+1,value=val)
    
    
    y = 1  # 在excel开始写的位置(y)
    x = 2  # 在excel开始写的位置(x)
    for i in  range(len(father_list)):
    
    
        for i in father_list[i]:  # 读取出相应的内容写到x,需要根据实际情况修改源文件分隔符
            #item = i.strip()  # 去除字符串两边的空格
            item1 = str(i)
            sheet.cell(row=x, column=y, value=item1)
            x += 1  # 另起一行
        y += 1  # 另起一列
        x = 2  # 初始成第一行
    
    xls.save(xlsx_Name)
    print("Complete Task!")
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
  • 相关阅读:
    34.LengthFieldBasedFrameDecoder代码使用
    GPU提升多分类问题
    Qt多媒体模块QMediaPlayer
    vue api封装
    java的继承特性和方法重写
    渗透测试——formatworld(2)
    Qt QLable 字符过长省略
    2023.10.8 面试
    使用基于SSIM的CNN进行环路滤波
    优思学院|精益六西格玛中的8大浪费是什么?
  • 原文地址:https://blog.csdn.net/qq_37405118/article/details/126073555