Re: stripping fields from xml file into a csv

2010-02-28 Thread Stefan Behnel
Hal Styli, 01.03.2010 00:15: > Stefan, I was happy to see such concise code. > Your python worked with only very minor modifications. > > Hai's test xml data *without* the first and last line is close enough > to the data I am using: > > > > > > > > ... quirky. > > I get a large file given

Re: stripping fields from xml file into a csv

2010-02-28 Thread Hal Styli
On 28 Feb, 19:20, Stefan Behnel wrote: > Hai Vu, 28.02.2010 17:41: > > > By the way, Stefan, I am using Python 2.6. Do you know the differences > > between ElementTree and cElementTree? > > Use cElementTree, it's implemented in C and a lot faster and more memory > friendly. > > http://effbot.org/z

Re: stripping fields from xml file into a csv

2010-02-28 Thread Stefan Behnel
Hai Vu, 28.02.2010 17:41: > By the way, Stefan, I am using Python 2.6. Do you know the differences > between ElementTree and cElementTree? Use cElementTree, it's implemented in C and a lot faster and more memory friendly. http://effbot.org/zone/celementtree.htm#benchmarks http://codespeak.net/lxm

Re: stripping fields from xml file into a csv

2010-02-28 Thread Hai Vu
On Feb 28, 12:05 am, Stefan Behnel wrote: > Hal Styli, 27.02.2010 21:50: > > > I have a sed solution to the problems below but would like to rewrite > > in python... > > Note that sed (or any other line based or text based tool) is not a > sensible way to handle XML. If you want to read XML, use a

Re: stripping fields from xml file into a csv

2010-02-28 Thread Roland Mueller
2010/2/28 Stefan Behnel > Roland Mueller, 28.02.2010 13:01: > > The stylesheet is test.xsl and the insput data test.xml. The following > > Python code the applies the stylesheet on the input data and puts the > output > > into foo. > > > > Python code: > > #!/usr/bin/python > > import sys > > imp

Re: stripping fields from xml file into a csv

2010-02-28 Thread Stefan Behnel
Roland Mueller, 28.02.2010 13:01: > The stylesheet is test.xsl and the insput data test.xml. The following > Python code the applies the stylesheet on the input data and puts the output > into foo. > > Python code: > #!/usr/bin/python > import sys > import libxml2 > import libxslt > > styledoc =

Re: stripping fields from xml file into a csv

2010-02-28 Thread Roland Mueller
Hello, 2010/2/28 Stefan Behnel > Hal Styli, 27.02.2010 21:50: > > I have a sed solution to the problems below but would like to rewrite > > in python... > > Note that sed (or any other line based or text based tool) is not a > sensible way to handle XML. If you want to read XML, use an XML parse

Re: stripping fields from xml file into a csv

2010-02-28 Thread Stefan Behnel
Hal Styli, 27.02.2010 21:50: > I have a sed solution to the problems below but would like to rewrite > in python... Note that sed (or any other line based or text based tool) is not a sensible way to handle XML. If you want to read XML, use an XML parser. They are designed to do exactly what you w

Re: stripping fields from xml file into a csv

2010-02-27 Thread Hai Vu
On Feb 27, 12:50 pm, Hal Styli wrote: > Hello, > > Can someone please help. > I have a sed solution to the problems below but would like to rewrite > in python... > > I need to strip out some data from a quirky xml file into a csv: > > from something like this > > < . cust="dick" product=

Re: stripping fields from xml file into a csv

2010-02-27 Thread Zaphod
On Sat, 27 Feb 2010 12:50:38 -0800, Hal Styli wrote: > Hello, > > Can someone please help. > I have a sed solution to the problems below but would like to rewrite in > python... > > I need to strip out some data from a quirky xml file into a csv: > > from something like this > > < . cust="

Re: stripping fields from xml file into a csv

2010-02-27 Thread John Bokma
Hal Styli writes: > Hello, > > Can someone please help. > I have a sed solution to the problems below but would like to rewrite > in python... > > I need to strip out some data from a quirky xml file into a csv: > > from something like this > > < . cust="dick" product="eggs" ... quantity

stripping fields from xml file into a csv

2010-02-27 Thread Hal Styli
Hello, Can someone please help. I have a sed solution to the problems below but would like to rewrite in python... I need to strip out some data from a quirky xml file into a csv: from something like this < . cust="dick" product="eggs" ... quantity="12" > < cust="tom" pr