Re: Newbie Python & XML
"I have a situation at work. Will be receiving XML file which contains quote information for car insurance. I need to translate this file into a flat comma delimited file which will be imported into a software package. Each XML file I receive will contain information on one quote only. I have documentation on layout of flat file and examples of XML file (lot of fields but only container tags and field tags no DTD's,look easy enough). I am just starting to learn python and have never had to work with XML files before. Working in MS Windows environment. I have Python 2.4 with win32 extensions. " Sounds like the sort of thing I and others have done very easily with Amara: http://www.xml.com/pub/a/2005/01/19/amara.html Overall, if you're new to Python and XML, here are some resources: http://www.xml.com/pub/at/24 http://uche.ogbuji.net/tech/akara/nodes/2003-01-01/general-section -- Uche Ogbuji Fourthought, Inc. http://uche.ogbuji.nethttp://fourthought.com http://copia.ogbuji.net http://4Suite.org Use CSS to display XML, part 2 - http://www-128.ibm.com/developerworks/edu/x-dw-x-xmlcss2-i.html XML Output with 4Suite & Amara - http://www.xml.com/pub/a/2005/04/20/py-xml.htmlUse XSLT to prepare XML for import into OpenOffice Calc - http://www.ibm.com/developerworks/xml/library/x-oocalc/ Schema standardization for top-down semantic transparency - http://www-128.ibm.com/developerworks/xml/library/x-think31.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie Python & XML
LenS wrote: > I have a situation at work. Will be receiving XML file which contains > quote information for car insurance. I need to translate this file > into a flat comma delimited file which will be imported into a software > package. Each XML file I receive will contain information on one quote > only. I have documentation on layout of flat file and examples of XML > file (lot of fields but only container tags and field tags no > DTD's,look easy enough). I am just starting to learn python and have > never had to work with XML files before. Working in MS Windows > environment. I have Python 2.4 with win32 extensions. > > 1. What else do I need I recommend ElementTree for XML processing in Python http://effbot.org/zone/element-index.htm and the Python-tutor mailing list for getting started with Python: http://mail.python.org/mailman/listinfo/tutor Kent -- http://mail.python.org/mailman/listinfo/python-list
Re: Newbie Python & XML
"LenS" <[EMAIL PROTECTED]> writes: > I have a situation at work. Will be receiving XML file which contains > quote information for car insurance. I need to translate this file > into a flat comma delimited file which will be imported into a software > package. Each XML file I receive will contain information on one quote > only. I have documentation on layout of flat file and examples of XML > file (lot of fields but only container tags and field tags no > DTD's,look easy enough). I am just starting to learn python and have > never had to work with XML files before. Working in MS Windows > environment. I have Python 2.4 with win32 extensions. > > 1. What else do I need Well, if the XML file format is going to be fixed, there's no difficulty here. import the parseString from dom.minidom Figure out how many levels of container the XMl doc has. and descend using the childNodes one or more times till you reach the data. Data nodes are of nodeType == 3. Iterate over them using nodeValue on each. Put them into a list and then paste you list together using COMMAS or other delimiter. This is the quick and dirty way! Will barf totally if your upstream data source throws you a curve. HTH > 2. Any examples of program doing the same. > 3. Have read some stuff that indicates I may need ? schema of XML > layout Perhaps. But probably not unless you are trying to build a highly flexible parser. > > The rating company will ftp a quote realtime to a dir on my system. > the python program will then have to poll the dir for new files and > automaticly translate and initiate import. A more elegant way of doing this is to pipe the FTP server log data through a running process and if the file matches one that requires this XML treatment, do it in real time. May not be worth the trouble to implement in a low volume system however. -- --- Jerry Sievers 305 854-3001 (home) WWW ECommerce Consultant 305 321-1144 (mobilehttp://www.JerrySievers.com/ -- http://mail.python.org/mailman/listinfo/python-list
Newbie Python & XML
I have a situation at work. Will be receiving XML file which contains quote information for car insurance. I need to translate this file into a flat comma delimited file which will be imported into a software package. Each XML file I receive will contain information on one quote only. I have documentation on layout of flat file and examples of XML file (lot of fields but only container tags and field tags no DTD's,look easy enough). I am just starting to learn python and have never had to work with XML files before. Working in MS Windows environment. I have Python 2.4 with win32 extensions. 1. What else do I need 2. Any examples of program doing the same. 3. Have read some stuff that indicates I may need ? schema of XML layout The rating company will ftp a quote realtime to a dir on my system. the python program will then have to poll the dir for new files and automaticly translate and initiate import. Any help appreciated Len Sumnler -- http://mail.python.org/mailman/listinfo/python-list