Re: [R] End of File for binary files

2010-01-24 Thread Duncan Murdoch
On 24/01/2010 2:12 PM, jim holtman wrote: If you are using readBin and want to read binary (and not 'character') data, then use 'raw' which will return a value if it encounters a binary zero and not think it is the end of a character string. I'm not sure I understand what you mean by reading b

Re: [R] End of File for binary files

2010-01-24 Thread Duncan Murdoch
On 24/01/2010 12:15 PM, Henrik Bengtsson wrote: On Sun, Jan 24, 2010 at 3:56 AM, Duncan Murdoch wrote: On 23/01/2010 10:40 PM, rn00b wrote: I am using readBin to continuously read characters from the binary file. I'm trying to figure out how many characters are in the file. What I would like t

Re: [R] End of File for binary files

2010-01-24 Thread jim holtman
If you are using readBin and want to read binary (and not 'character') data, then use 'raw' which will return a value if it encounters a binary zero and not think it is the end of a character string. It is easy enough to setup a test file and try out a couple of the options to see what happen. No

Re: [R] End of File for binary files

2010-01-24 Thread Henrik Bengtsson
On Sun, Jan 24, 2010 at 3:56 AM, Duncan Murdoch wrote: > On 23/01/2010 10:40 PM, rn00b wrote: >> >> I am using readBin to continuously read characters from the binary file. >> I'm >> trying to figure out how many characters are in the file. What I would >> like >> to do is something like >> (while

Re: [R] End of File for binary files

2010-01-24 Thread Duncan Murdoch
On 23/01/2010 10:40 PM, rn00b wrote: I am using readBin to continuously read characters from the binary file. I'm trying to figure out how many characters are in the file. What I would like to do is something like (while! EOF) { charRead <-.Internal(readBin(con,"character",1L,NA,TRUE,swap)) i++ }

Re: [R] End of File for binary files

2010-01-23 Thread jim holtman
Are you really trying to read in binary? You are asking for characters which would be a null terminated string. If you are trying to read in binary zeroes, this will not work. What you need to do is to use 'raw'. Actually you should create a R script to test out the various conditions you want.

Re: [R] End of File for binary files

2010-01-23 Thread rn00b
I am using readBin to continuously read characters from the binary file. I'm trying to figure out how many characters are in the file. What I would like to do is something like (while! EOF) { charRead <-.Internal(readBin(con,"character",1L,NA,TRUE,swap)) i++ } I'm not clear on how to determine th

Re: [R] End of File for binary files

2010-01-23 Thread jim holtman
If you are reading a 'binary' file, then the end of file is when you read the last byte; the system will tell you. Exactly what are you trying do to? When you do a read, you typically request the number of bytes to read and then the system returns the number of bytes read. But since you did not g

[R] End of File for binary files

2010-01-23 Thread rn00b
Hello, I'm new to R and I'm writing a function to read binary tables (the binary version of read.table essentially). I'm having trouble figuring out how to determine when I reach end-of-file. Can anybody please help? thanks! -- View this message in context: http://n4.nabble.com/End-of-File-for