[Expat-discuss] expat and compressed xml
Thomas Younger
tyounger at questertangent.com
Tue Jan 12 23:51:59 CET 2010
zcat
________________________________________
From: expat-discuss-bounces+tyounger=questertangent.com at libexpat.org [expat-discuss-bounces+tyounger=questertangent.com at libexpat.org] On Behalf Of gilbert F. [gilbertff at gmail.com]
Sent: Tuesday, January 12, 2010 2:37 PM
To: expat-discuss at libexpat.org
Subject: [Expat-discuss] expat and compressed xml
Hello,
Here is a quick question about parsing xml .gz file. Here is what I
did. With the following script
req = urllib2.Request(query_url)
xml_file = urllib2.urlopen(req).read()
I downloaded a compressed xml file. The file has a suffix of ".gz".
Now I used
p = xml.parsers.expat.ParserCreate()
p.ParseFile(xml_file)
The last line gave
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: argument must have 'read' attribute
xml_file is not a file. It is a string therefore it gave an error.
Anybody knows how to uncompress the downloaded file? I know that
"gunzip" can be used to uncompress ".gz" files, however I do not know
how to get the uncompressed result.
Any help? Thanks so much.
_______________________________________________
Expat-discuss mailing list
Expat-discuss at libexpat.org
http://mail.libexpat.org/mailman/listinfo/expat-discuss
More information about the Expat-discuss
mailing list