Skip to content

Test Binary File

3 messages · Jason Rupert, jim holtman, Duncan Murdoch

#
I've got an error with the way I'm using readBin on a binary file of unknown internal structure.  I know the structure consists of rows and columns, but I'm not sure how many of each.  

So, does anyone know of a valid test set of binary data that I could reference while trying to figure out the technique of using readBin? 

It would be really helpful to try out readBin on a readily available and understood binary file instead of starting with one of dubious internal structure.  

Thank you again for your help and feedback.
#
Do you know how it is structured?  Is it 64-bit floating point, 32-bit
floating point, 64 bit integer, 32 bit integer, byte values, etc.?  If
we know the structure, then we can determine how to decode the
information.
On Wed, Nov 25, 2009 at 7:34 AM, Jason Rupert <jasonkrupert at yahoo.com> wrote:

  
    
#
On 25/11/2009 7:34 AM, Jason Rupert wrote:
You can write your own.  For example,

f <- tempfile()
writeBin(as.numeric(1:100), f)

The hexView package is very nice for seeing what you've got:

library(hexView)
viewRaw(f)

which will show something like this:

 0  :  00 00 00 00 00 00 f0 3f 00 00 00 00 00 00 00 40  |  .......?.......@
 16  :  00 00 00 00 00 00 08 40 00 00 00 00 00 00 10 40  |  ....... at .......@
 32  :  00 00 00 00 00 00 14 40 00 00 00 00 00 00 18 40  |  ....... at .......@
...

viewRaw(f, human="real")

will show

  0  :  00 00 00 00 00 00 f0 3f 00 00 00 00 00 00 00 40  |    1   2
 16  :  00 00 00 00 00 00 08 40 00 00 00 00 00 00 10 40  |    3   4
 32  :  00 00 00 00 00 00 14 40 00 00 00 00 00 00 18 40  |    5   6
 48  :  00 00 00 00 00 00 1c 40 00 00 00 00 00 00 20 40  |    7   8
...

Duncan Murdoch