Re: [Tutor] Reading .gz files

2011-07-29 Thread Steven D'Aprano
Oh, I forgot to say something else... Hanlie Pretorius wrote: f1 = 'GSMaP_MVK+.20050101.00.0.1deg.hourly.v484.gz' f2 = ''text.txt.gz' if1 = gzip.open(f1, 'rb') if2 = gzip.open(f2,'rb') try: print if1.read() print 'done with f1' Once you've read the file once, the file pointer is at the

Re: [Tutor] Reading .gz files

2011-07-29 Thread Steven D'Aprano
Hanlie Pretorius wrote: [code] import gzip f1 = 'GSMaP_MVK+.20050101.00.0.1deg.hourly.v484.gz' f2 = ''text.txt.gz' if1 = gzip.open(f1, 'rb') if2 = gzip.open(f2,'rb') try: print if1.read() print 'done with f1' print if2.read() print 'done with f2' finally: if1.close() if2.close

[Tutor] Reading .gz files

2011-07-29 Thread Hanlie Pretorius
Hi, I'm working on Windows XP with Python 2.6. I need to read and process hundreds of binary files that are in the .gz archive format. I found a site (http://www.doughellmann.com/PyMOTW/gzip/) and tried their code with two files: one of the hundreds of files that I need to process (f1 below) and