reading from a gzip file

MRAB google at mrabarnett.plus.com
Wed Jun 18 07:33:37 EDT 2008


On Jun 18, 10:10 am, Nader <n.em... at gmail.com> wrote:
> Hello,
>
> I have a gzip file and I try to read from this file withe the next
> statements:
>
>  gunziped_file = gzip.GzipFile('gzip-file')
>  input_file = open(gunziped_file,'r')
>
> But I get the nezt error message:
>
> Traceback (most recent call last):
>   File "read_sfloc_files.py", line 131, in ?
>     input_file = open(gunziped_file,'r')
> TypeError: coercing to Unicode: need string or buffer, instance found
>
> I think that I do some mistake. Would some body tell me what is my
> mistake?
>
You're opening the gzip file and then passing the gzip file object as
a filename to open(). The documentation for the gzip module is at
http://www.python.org/doc/lib/module-gzip.html.



More information about the Python-list mailing list