[R] Reading gzip data from a non zero file offset
Gregory Jefferis
jefferis at mrc-lmb.cam.ac.uk
Fri Sep 11 16:37:49 CEST 2009
Dear R users,
I have a file that contains a text header followed by a gzipped data chunk.
I thought I would be able to read this by doing something like this.
con<-file('myfile','rb')
header<-readLines(con,10)
gzf<-gzcon(con)
data<-readBin(gzf,"int",n=1e7)
But what I find is that gzcon resets the original connection back to the
beginning of the file rather than reading from its current location.
Would anyone have any suggestions for how to handle this in R? Right now I
am using system to call "tail" to copy the gzipped data into a temporary
file, but that isn't portable.
Many thanks for your help,
Greg.
--
Gregory Jefferis, PhD
Division of Neurobiology
MRC Laboratory of Molecular Biology,
Hills Road,
Cambridge, CB2 0QH, UK.
http://www2.mrc-lmb.cam.ac.uk/NB/jefferis_g
http://www.neuroscience.cam.ac.uk/directory/profile.php?gsxej2
http://flybrain.stanford.edu
More information about the R-help
mailing list