[R] Large Binary file reader for Simple minds

Duncan Murdoch murdoch at stats.uwo.ca
Mon Jun 18 19:27:32 CEST 2007


On 6/18/2007 12:17 PM, Todd Remund wrote:
> I'm more like a caveman when it comes to programming tools.  So, with that 
> in mind, is there a way to use readBin in a batch format to read in pieces 
> of a large binary file?  Thank you for the consideration of my question.

I'm not sure what you mean by "batch format", but you can use readBin to 
  read bits and pieces of a file, by opening a connection to the file 
and reading from there.  For example, to read a single unsigned byte 
value at offset 10000, do something like this:

con <- file("myfile.dat", open="rb")  # open for binary reading
seek(con, 10000)
result <- readBin(con, "integer", size=1, signed=FALSE)
close(con)

Duncan Murdoch



More information about the R-help mailing list