reading from a gzip file

N

Nader

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?

Nader
 
M

MRAB

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,992
Messages
2,570,220
Members
46,805
Latest member
ClydeHeld1

Latest Threads

Top