问题
Since I am not a programmer I got stuck solving this probably trivial problem: I would like to extract numeric values from binary file (example.Lis) using R. First 256 bytes contain a header. I know the header structure therefore I was able to decode its content. For instance, according the format description, OLE DATE information is stored in bytes 8-15 as a double data type. To read this, I simply used following command:
my.file = file("example.Lis", "rb")
headall<-readBin(my.file, raw(), n=256, size=1)
readBin(headall[9:16],double(),size=8,n=1)
[1] 42438.66
Header is followed by a series of 32-bit data records. Each record contain multiple integer values, so it is not possible to proceed byte-wise as in the header case. Is it somehow possible to read the file bit-wise to decode the numbers inside each record?
As the format description states (page 4), 32-bit words are encoded as follows:
来源:https://stackoverflow.com/questions/35919472/reading-binary-file-bitwise-in-r