reading from an 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

Matt Nordhoff

Nader said:
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

gzip.GzipFile() creates a file-like object. You don't call open() on it;
you use it directly.

$ echo foo >test
$ gzip test
$ python--
 

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,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top