'Read and extract information from 3 files (python)
I'am designing a code in python for extract information from a xml file with a function with two variables. The code is working with one file:
import re
def Readfiles(XFile):
Id=''
des=''
with open(XFile,"r",encoding="utf-8") as h:
for line in h:
wline = line.rstrip("\n")
if re.search("^ID\s{3}",wline):
res=re.search(r"^ID\s{3}",wline)
Id=res.group(1)
if re.search("^DE\s{3}",wline):
res=re.search("^DE\s{3}",wline)
des=res.group(1)
return(Id,des)
(Identificator,desc)=Readfiles("rte.xml", "pre.xml", "ytl.xml")
print("Nom:",Identificator)
print("Descrip:",desc)
On the other hand, I want to read more files (tree xml in the code) in a same time but it give me error.
Thank for your help.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
