Hi Scott,

Don't know if I understood your suggestion, correctly, but I tried:

[code]
import os
import gzip
import numpy as np

os.chdir('C:\\Hanlie\\data\\GsMAP\\2005-02\\01')

f1 = 'GSMaP_MVK+.20050201.00.0.1deg.hourly.v484.gz'
tmpfile = gzip.open(f1)

binvalues = np.fromfile(tmpfile)
[/code]

and got the error:
Traceback (most recent call last):
  File "C:\Hanlie\data\GsMAP\test.py", line 17, in <module>
    binvalues = np.fromfile(tmpfile)
IOError: first argument must be an open file

One of the other suggestions to my post worked, so I'm going with
that.

On Jul 29, 1:32 pm, Scott Sinclair <[email protected]>
wrote:
> On 29 July 2011 12:45, Hanlie Pretorius <[email protected]> wrote:
>
> > I need to read and process hundreds of GSMaP binary files that are in the
> > .gz archive format.
>
> > [output]
> > done with f1
> > Text to test gzip module.
> > done with f2
> > [/output]
>
> > This seems to indicate that something is wrong with f1 (the GSMaP
> > file), but I can unzip the file manually and read it with a python
> > script (code and output pasted after signature). I have hundreds of
> > GSMAP files that have unique archived file names, but they all unzip
> > to the same binary file, so I have to process the archived files in
> > the python script.
>
> Doesn't it work if you modify part of your pasted script as below?
>
> # read binary file and store its data in an array
> fp = 'C:\\out.00'
> tmpfile = open(fp, 'rb')
>
> Change to (untested):
>
> # read binary file and store its data in an array
> f1 = 'GSMaP_MVK+.20050101.00.0.1deg.hourly.v484.gz'
> tmpfile = gzip.open(f1)
>
> You could also simplify your code by using np.fromfile(tmpfile) to
> read the binary data.
>
> Cheers,
> Scott

Reply via email to