Displaying 20 results from an estimated 20000 matches similar to: "Reading 64-bit integers"
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 patch that does this is
given below. This passes "make
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) or
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):
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):
2008 Apr 28
4
R 2.7.0, match() and strings containing \0 - bug?
Hi,
A piece of my code that uses readBin() to read a certain file type is
behaving strangely with R 2.7.0. This seems to be because of a failure
to match() strings after using rawToChar() when the original was
terminated with a "\0" character. Direct equality testing with ==
still works as expected. I can reproduce this as follows:
> x <- "foo"
> y <-
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"
either. Not good.
I then looked at the R code for readBin, which
2009 Feb 11
1
Reading Binary Files
Hello
I'm encountering some difficulty correctly reading binary files. The binary
files store data as "short" rather than "double" , "int", or any of the
other modes of the vector being read.
The data represents a regular grid of size 419 rows by 264 columns, to make
it more interesting, the data are daily records, for a total of 37 years.
The file size is
2012 Feb 15
1
Using readBin to read binary "unformatted" output files from Fortran?
Hello,
I'm wondering if I can get some help with reading Fortran binary "unformatted" output files into R.
The Fortran output files were generated in Ubuntu 10.04 LTS using gfortran4.4, on a 32bit Intel Core 2 Duo 3.16 GHz machine, with little-endian and record marker lengths equal to 4.
The machine I'm currently trying to read this Fortran output file is a Macbook Pro
2008 Aug 22
2
How I can read the binary file with "different type"?
Hi all,
I have a binary file which have 8*100 bytes. The structure of the file is
as follows: every eigth bytes represent 2 data:the first four bytes is the
little-endian for integer, the next four bytes is the little-endian for
floating32. The structure of the following bytes is as the same as the first
eight bytes'.
As the function readBin only read the binary file with one structure
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
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 attention.
Which brings me
2005 Feb 17
1
socket problems (maybe bugs?)
Dear R Gurus,
for some purpose i have to use a socket connection, where i have to read
and write both text and binary data (each binary data package will be
preceeded by a header line).
When experimenting, i encountered some problems (with R-2.0.1 under
different Linuxes (SuSE and Gentoo)).
Since the default mode for socket connections is non-blocking,
i first tried socketSelect() in order to
2012 May 24
6
R does not recognise columns and rows as they are supposed to be
Dear All,
The code given bellow is to extract values of one region and write that to
a text file(there are 365 binary files in the directory).
The problem which I am facing is that all my files are binary with size of
360 rows and 720 columns.
I specified that in this line: file2<-matrix(data=file,ncol=720,nrow=360)
but I got an error : Error in mean(file2[X, Y], na.rm = TRUE) : subscript
2012 Apr 13
2
Can't read a binary file
Hi, I've read up on readBin() and chapter 6 in the R Data Import/Export manual, but I still can't read a binary file. Here is how the creator of the file described the code that would be needed in Fortran:
"Every record has a return in fortran. The length of each record is nx*ny*4. To read you would use the following:
nlayx = nx*ny*4
do iz=1,nz,4
read(binary file) var(1:nlayx)
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
- characters. \code{\link{readChar}} and \code{\code{writeChar}}
+
2009 Dec 17
1
Problem reading binaries created with fortran (More infos)
The structure of the file is clear (see below) the first line is made of
integers and doubles with the fifth being a text string followed by arrays
of double precision number.:
int1 int2 double1 double2 text int3 int4 int5
(array of double)
here is an example of file:
1 1 1.0 1.0 "HEAD" 160 224 3
23.4 34.5 ......
I tried to read the first line with readBin (results are copied below):
2008 May 29
2
Reading an "unsigned long long" using R readBin()
Sorry for the simple question, but I am trying to read an "unsigned
long long" using the R readBin() function. Can someone point me in
the right direction, or am I better off using C for such things? The
file that I am reading will have been produced on the same machine
that is doing the reading.
Thanks,
Sean
2012 Jun 12
1
Reading binary files
Hey guys,
I am currently trying to read in a binary file using this helpful manual:
http://www.ats.ucla.edu/stat/r/faq/read_binary.htm Reading binary files
I also have the detailed format description from the developer. But somehow
the reading of the file does still not work properly. The first entry in the
file is the following, according to the manufacturer:
"String containing 4 one-byte
2006 Oct 21
2
Possible bugs in 'seek' and 'readBin'
I found that
seek(..., origin = 'current', ...)
and
readBin(..., what = 'integer', ...)
or 'int'
do not work correctly.
Did anyone have the same experience?
2012 Jun 19
1
seek(), skip by bits (not by bytes) in binary file
Hello,
Has a function been built that will skip to a certain bit in a binary file?
As of 2009 the answer was 'no':
http://r.789695.n4.nabble.com/read-binary-file-seek-td900847.html
https://stat.ethz.ch/pipermail/r-help/2009-May/199819.html
If you feel I don't need to (like in the links above), please provide some
help. (Note this is my first time working with binary files.)
I'm