search for: readbin

Displaying 20 results from an estimated 237 matches for "readbin".

2009 May 18
2
readBin on binary non-blocking connections (Windows & Unix differences/bugs)
R-devel: I am encountering a consistency issue using socketConnection and readBin with *non-blocking* connections on Unix and Windows XP (no Vista to test). I am a bit confused by the behavior of *non-blocking* connections under Windows specifically. When calling readBin on a non-blocking connection when there is no data to read on the socket, the connection under Unix will re...
2006 Jun 28
2
read file with readBin (the file was saved with a C-routine)
Hello! I have problems with using of "readBin" to read files, which was written in C with "fwrite". In the C-File there is the following Code: fwrite(MyitINI,sizeof(itINItype),1,outfile); where MyitINI is a structure of the following form typedef struct{ int KernelFileSave; /* Determined, if Systemmatrix saved or not.*...
2004 Jun 01
2
Importing binary data
...the import or handling such large data sets? Thanks in advance! Uli read.DET.data <- function ( f ) { counter <- 1 spk.v <- c() imp.v <- c() score.v <- c() th.v <- c() ses.v <- c() rec.v <- c() type.v <- c() fid <- file( f ,"rb") tempi <- readBin(fid , integer(), size=1, signed=FALSE) while ( length(tempi) != 0) { spk.v[ counter ] <- tempi imp.v[ counter ] <- readBin(fid, integer(), size=1, signed=FALSE) score.v[ counter ] <- readBin(fid, numeric(), size=4) type.v[ counter ] <- readBin(fid, character()) th.v[ counter...
2007 Jan 26
1
readBin is much slower for raw input than for a file
Dear all, I'm trying to write an efficient binary file reader for a file type that is made up of several fields of variable length, and so requires many small reads. Doing this on the file directly using a sequence of readBin() calls is a bit too slow for my needs, so I tried buffering the file into a raw vector and reading from that ("loc" is the equivalent of the file pointer): fileSize <- file.info(fileName)$size connection <- file(fileName, "rb") bytes <- readBin(connection, "raw&q...
2007 Jan 26
1
readBin is much slower for raw input than for a file
Dear all, I'm trying to write an efficient binary file reader for a file type that is made up of several fields of variable length, and so requires many small reads. Doing this on the file directly using a sequence of readBin() calls is a bit too slow for my needs, so I tried buffering the file into a raw vector and reading from that ("loc" is the equivalent of the file pointer): fileSize <- file.info(fileName)$size connection <- file(fileName, "rb") bytes <- readBin(connection, "raw&q...
2019 Nov 18
2
readBin should check that its endian argument is a legal value
I think it would be helpful if readBin checked that its endian argument is a legal value. Why? I was reviewing some of our code and noticed that the author had readBin(..., endian="network") and never having heard of "network", I looked at the man page for readBin, and it hadn't heard of "network" eith...
2006 Sep 27
2
Single Precision (4 byte) floats with readBin
I would like to use readBin to read a binary data file. Most of the data is 4-byte floating point but, for some reason, only double precision appears to be offered. I tried fVariable=readBin(iFile,what=single()); and got 35.87879 which looks believable except that the correct value is 3.030303. I then tried fVariable=read...
2002 Mar 05
3
reading 2-byte integers using readBin and connections
Hi folks: This may be a stupid question, but I cannot seem to find a way to tell readBin that I want to read 2-byte integers from the connection. The input file is 150,720 bytes long containing 75,360 short (2-byte) integers. But specifying "integer" or "int" for what in readBin only returns me a vector of length 37680, leading me to believe that sizeof(integer) o...
2013 May 08
1
getting corrupted data when using readBin() after seek() on a gzfile connection
Hi, I'm running into more issues when reading data from a gzfile connection. If I read the data sequentially with successive calls to readBin(), the data I get looks ok. But if I call seek() between the successive calls to readBin(), I get corrupted data. Here is a (hopefully) reproducible example. See my sessionInfo() at the end (I'm not on Windows, where, according to the man page, seek() is broken). ## Generate data with a re...
2006 Jun 02
1
Typo fix for readBin.Rd
Hi, The man page for readBin has a small typo: --- a/src/library/base/man/readBin.Rd +++ b/src/library/base/man/readBin.Rd @@ -58,7 +58,7 @@ writeBin(object, con, size = NA, endian \code{readBin} and \code{writeBin} read and write C-style zero-terminated character strings. Input strings are limited to 10000 - chara...
2007 Dec 31
1
readBin differences on Windows and Linux/mac
I have been trying to use the gunzip function in the R.utils package. It opens a connection to a gzfile, uses readBin to read from that connection, and then uses writeBin to write out the raw data to a new file. This works as expected under linux/mac, but under Windows, I get: Error in readBin(inn, what= raw(0), size = 1, n=BFR.SIZE) : negative length vectors are not allowed A simple traceback shows the erro...
2012 May 03
2
Help with readBin
I'm trying to read a binary file created by a fortran code using readBin and readChar. Everything reads fine (integers and strings) except for double precision numbers, they are read as huge or very small number (1E-250,...). I tried various endianness, swap, But nothing has worked so far. I also tried on R 64 bit for linux and windows (R 2.14) and R 2.11 on windows XP...
2011 Sep 01
4
readBin fails to read large files
Posting for a friend Begin forwarded message: From: "Geier, Florian" <florian.geier08@imperial.ac.uk<mailto:florian.geier08@imperial.ac.uk>> Subject: Fwd: readBin fails to read large files Date: September 1, 2011 4:10:53 PM GMT+01:00 To: Begin forwarded message: Date: 1 September 2011 16:01:45 GMT+01:00 Subject: readBin fails to read large files Dear all, I am trying to read a large file (~2GB) of unsigned ints into R. Using the command: raw<-readB...
2003 Feb 13
5
ESRI shape file import and time-space models
Dear R user, I am running R under Windows 2000. I am looking for a routine for importing - shape files (ESRI) into R - dbase files (FOXPRO) into R and I am looking for time-space models for description and prediction of Bernoulli-, Binomial- and Poissonvaraibles. Thank's a lot for a reply. Sincerely yours, Ekkehardt Altpeter Swiss Federal Office of Public
2019 Dec 18
0
readBin should check that its endian argument is a legal value
Thank you for reporting this problem, R-devel now has a check in readBin and writeBin. I've identified two CRAN packages with an incorrect value for "endian" and reported to maintainers, unfortunately in their case the intention was to specify "little". Best Tomas On 11/18/19 11:22 PM, Jennifer Lyon wrote: > I think it would be helpful i...
2002 Nov 29
2
readBin or writeBin adds extra nulls (PR#2333)
Full_Name: Ken Yap Version: 1.6.1 OS: Linux (SuSE 8.0) Submission from: (NULL) (129.78.64.5) I'm trying to copy a file using readBin and writeBin. (The reason is to be able to pipe PostScript or PDF output to a socket later, this is just an experiment.) I do: zz <- file("foo.ps", "rb") r <- readBin(zz, character(), 1000000) yy <- file("bar.ps", "wb") writeBin(r, yy, character(),...
2009 Aug 11
1
readBin() arg check has unnecessary overhead (patch included)
Dear all, The version of readBin() in R-devel includes a use of match(), through `%in%`, which can affect its performance significantly. By using primitives instead of the rather expensive call to match(), I reduce the time spent inside readBin() by more than 30% in some of my code (part of the tractor.base package). A simple patc...
2011 Mar 29
2
Reading 64-bit integers
Dear all, I see from some previous threads that support for 64-bit integers in R may be an aim for future versions, but in the meantime I'm wondering whether it is possible to read in integers of greater than 32 bits at all. Judging from ?readBin, it should be possible to read 8-byte integers to some degree, but it is clearly limited in practice by R's internally 32-bit integer type: > x <- as.raw(c(0,0,0,0,1,0,0,0)) > (readBin(x,"integer",n=1,size=8,signed=F,endian="big")) [1] 16777216 > x <- as.raw(...
2005 Oct 12
1
Questions about readBin function (Was: dec2bin?)
Hi, The latest version of R had some changes to functions "readbin() and writeBin() [which] now support raw vectors as well as filenames and connections.". As a result I am working on retiring "raw2bin" and "bin2raw" functions from "caTools" package which do exactly the same. Thanks to Prof. Ripley for bringing this change to my...
2009 May 11
3
readBin: read from defined offset TO defined offset?
Hello, With the help of "seek" I can start "readBin" from any byte offset within my file that I deem appropriate. What I would like to do is to be able to define the endpoint of that read as well. Is there any solution to that already out there? Thanks for any hints, Joh