xml_AOI -1.7z

上传者: 39146438 | 上传时间: 2021-04-01 17:01:11 | 文件大小: 16KB | 文件类型: 7Z
import xml.etree.ElementTree as ET import traceback import pandas as pd import datetime filehoder=r'D:\myproject_python\AOI\xml_AOI -1\xml_AOI' filename=['V-NC419764','V-NC420305','NC421886'] with open(r'D:\myproject_python\AOI\xml_AOI -1\xml_AOI\0_V-NC419764.txt',"r") as f: file_section_list=f.read() f.close() print(file_section_list) def cutXmlSentences(file_str): """ 说明:一个xml文件中包含多个html段,进行分割. :param file: :return: """ final_list = [] output = "" str_list = file_str.split("\n") for i in range(len(str_list)): if str_list[i] != "\n": output += str_list[i] else: final_list.append(output) output = "" final_list.append(output) tmp_list = list(filter(lambda s: s != '' and s != ' ' and s != '\n', final_list)) return tmp_list def traversexml(element): """ 说明:遍历element所有子节点. :param element: :return: """ # print (len(element)) if len(element) > 0: for child in element: print(child.tag, "----", child.attrib) traversexml(child) def ReadXml(xml_string): """ 说明:解析xml文件成root. :param xml_string: :return: """ root = None if (xml_string): try: # print("xmlstring provided") root = ET.fromstring(xml_string) except Exception: # as e: print(xml_string) print("parse xmlstring failed!") finally: return root child_root = ReadXml(file_section_list) final_data_dict = {} for header in child_root.findall('header'): #这些元素只出现一次 for serialnumber in header.findall("serialnumber"): final_data_dict['boardid'] = serialnumber.text.strip("V-") for dt in header.findall("datetime"): date_time = datetime.datetime.strptime(dt.text.replace(".000+08:00", "").replace("T", " "),"%Y-%m-%d %H:%M:

文件下载

资源详情

[{"title":"( 15 个子文件 16KB ) xml_AOI -1.7z","children":[{"title":"xml_AOI","children":[{"title":"19_V-NC420305.txt <span style='color:#111;'> 1.94KB </span>","children":null,"spread":false},{"title":"0_V-NC419764.docx <span style='color:#111;'> 16.55KB </span>","children":null,"spread":false},{"title":"0_V-NC419764.txt <span style='color:#111;'> 2.85KB </span>","children":null,"spread":false},{"title":"27_V-NC421886.txt <span style='color:#111;'> 1.94KB </span>","children":null,"spread":false},{"title":"1_V-NC419764.txt <span style='color:#111;'> 2.81KB </span>","children":null,"spread":false},{"title":"11_V-NC420305.txt <span style='color:#111;'> 2.86KB </span>","children":null,"spread":false},{"title":"10_V-NC420305.txt <span style='color:#111;'> 2.86KB </span>","children":null,"spread":false},{"title":"18_V-NC420305.txt <span style='color:#111;'> 3.39KB </span>","children":null,"spread":false},{"title":"7_V-NC419764.txt <span style='color:#111;'> 2.69KB </span>","children":null,"spread":false},{"title":"21_V-NC420305.txt <span style='color:#111;'> 2.70KB </span>","children":null,"spread":false},{"title":"13_V-NC420305.txt <span style='color:#111;'> 2.86KB </span>","children":null,"spread":false},{"title":"6_V-NC419764.txt <span style='color:#111;'> 2.69KB </span>","children":null,"spread":false},{"title":"29_V-NC421886.txt <span style='color:#111;'> 1.94KB </span>","children":null,"spread":false},{"title":"17_V-NC420305.txt <span style='color:#111;'> 3.39KB </span>","children":null,"spread":false},{"title":"9_V-NC419764.txt <span style='color:#111;'> 1.94KB </span>","children":null,"spread":false}],"spread":false}],"spread":true}]

评论信息

免责申明

【只为小站】的资源来自网友分享,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,【只为小站】 无法对用户传输的作品、信息、内容的权属或合法性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论 【只为小站】 经营者是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。
本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二条之规定,若资源存在侵权或相关问题请联系本站客服人员,zhiweidada#qq.com,请把#换成@,本站将给予最大的支持与配合,做到及时反馈和处理。关于更多版权及免责申明参见 版权及免责申明