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
