def inner(path, node): for item in os.listdir(path): itempath = path + '/' + item if os.path.isdir(itempath): newnode = ObjDict() node[item] = newnode inner(itempath, newnode) else: if item == 'package.xml': continue name = itempath.split('/')[-1] if trim_suffixes: name = name[:name.find('.')] try: if return_type == 'binary': node[name] = open(itempath, 'rb').read() elif return_type == 'dict': node[name] = ObjDict.deepclone( xmltodict.parse( open(itempath, 'rb').read())) elif return_type == 'records': node[name] = flatten_dict( xmltodict(open(itempath, 'rb').read())) elif return_type == 'parsed': node[name] = ObjDict.deepclone( XmlParser(file_path=itempath)) except: node[name] = open(itempath, 'rb').read()
def dequeue(self,*args,**kwargs): try : retVal = method(self,*args,**kwargs) if utils.comm_queue.__len__() != 0: xmlObj = utils.comm_queue.pop() #convert the XML object into serviceDict serviceDict = xmltodict(xmlObj) return retVal except : pass
def xml2dict(conf_file): confile = open(conf_file,'r') conf_xml = confile.read() confile.close() dict = xmltodict(conf_xml,'utf-8') return dict
def from_xml(cls, xml_string): attributes = xmltodict(xml_string) return cls(**attributes)
x[0] y = np.unique(x) import numpy as np y = np.unique(x) len(y) y[0] x[0] y[0] xmldoc.w df[0] df.head() df.keys() df['ElemName'] import xmltodict import xmltodict xx = xmltodict('dzg/FFM_DEZ_180701.csv') with open('dzg/FFM_DEZ_180701.csv') as fd: xx = xmltodict.parse(fd.read()) with open('dzg/FFM_DEZ_180701.csv') as fd: xx = xmltodict.parse(fd.read(), encoding=''ISO-8859-1') with open('dzg/FFM_DEZ_180701.csv') as fd: xx = xmltodict.parse(fd.read(), encoding='ISO-8859-1') with open('dzg/FFM_DEZ_180701.csv') as fd: xx = xmltodict.parse(fd.read(), encoding='latin1') import lxml import xml.etree.ElementTree as ET tree = ET.parse('dzg/FFM_DEZ_180701.csv') tree = ET.parse('dzg/static.xml') with open('dzg/static.xml') as fd: xx = xmltodict.parse(fd.read(), encoding='latin1')