[Chicago] Need Python -2.4.3 help
Harry aman
nharry99 at gmail.com
Mon Mar 17 15:13:19 CET 2014
Hi,
I'm new to Python. The installed Python version is 2.4.3 in Linux
and our admins are not willing to upgrade it due to other comparability
issues.
The issue is related to reading XML file and convert it to a txt
file for further process.
Here's the code example.
#read XML file and convert into text file for further process
from xml.dom.minidom import parse, parseString
dom=parse('/mnt/usr/Test.xml')
outf = open ('/mnt/usr/Test.txt','w')
attr_list = [
'col1',
'col2',
'col3',
'col4'
]
for row in dom.childNodes[0].getElementsByTagName('z:row'):
for attr in attr_list:
if attr in row.attributes.keys():
outf.write(row.attributes[attr].value.encode("utf-8")+"\t")
else: outf.write("\t")
outf.write("\n")
outf.close()
I didn't see any good example to do this. Please let me know your
suggestions.
Thanks in Advance.
Regards
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/chicago/attachments/20140317/348dddaf/attachment.html>
More information about the Chicago
mailing list