Displaying 20 results from an estimated 7000 matches similar to: "pipe and binary i/o (on Linux)"
2002 Aug 05
1
pipe and binary i/o
I often want to use "pipe" with "readBin" to read (binary) data from the
standard output of a Perl or C program. For that I need "pipe" to work with
the "open='rb'" option. It never worked for me, and after a look at the
connections.c file, I see that in "pipe_open" the mode gets passed directly
to "popen" (I'm using Linux on
2013 Dec 13
0
how to use the readBin ?
how to use the readBin ?
i want to write the extended ascii character `Œ` into a file named c:/testbin,
and read it in the R console ,display it as `Œ` in R console.
now i can write it .
zz <- file("c:/testbin", "wb")
writeBin(charToRaw("\u0152"), zz)
close(zz)
when i open the file with office(encoding=utf-8),i can see `Œ`,whay i can not read it with readBin?
2010 Jun 22
4
seek() and gzfile() on 32-bit R2.12.0 in linux
I have installed both 32-bit and 64-bit versions of R2.12.0 (2010-06-15
r52300) on my Ubuntu 10.04 64-bit system. I observe the following behavior
when running the examples from base::connections. There appears to be a
problem with seek() on a .gz file when using a 32-bit installation of
R2.12.0, but the problem doesn't appear in the 64-bit installation. I
realize that seek() has been
2011 Feb 04
2
Strange behaviour of read and writeBin
To me it seems like writeBin() writes one char/byte more than expected.
> con <- file("testbin", "wb")
> writeBin("ttccggaa", con)
> close(con)
> con <- file("testbin", "rb")
> readBin(con, what="character")
[1] "ttccggaa"
> seek(con, what=NA)
[1] 9
> close(con)
> con <-
2006 Oct 02
0
2.3.1: interacting bugs in load() and gzfile() (PR#9271)
Hello,
If repeated calls are made to save() using the same pre-opened gzfile
connection to a file, and then the connection is closed, the objects
saved by the second and subsequent calls are not correctly restored by
repeated calls to load() with a new gzfile connection to the same file.
What follows are a session exposing the bugs, analysis (see ANALYSIS),
patches (see PATCHES), and a session
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,
2007 Feb 16
0
R_decompress1 and zlib
Dear all,
I have a problem similar to what was already posted about two years ago
(http://tolstoy.newcastle.edu.au/R/help/05/01/10011.html): I have a binary
file, which contains a header and data compressed by zlib and written to
the file as unsigned character. Here is, what I try to do:
> zz <- file(in.file, 'rb')
> ## the header has to be read in three parts due to the
2001 Feb 15
2
Reading single precision floats from binary file
Dear all,
I have a few files with binary data written by a C program a friend wrote.
I allready have program to read these files, Thomas Lumley and Prof Brian
D Ripley was kind enough to respond to a question to this list earlier
with some code that works perfectly, so this is really no problem, it is
more out curiousity.
Most of my files consists of 40000 single precision floats, and I figured
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):
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
2008 Jan 23
0
writeBin doesn't "send" until readBin executed
Hi all -
I'm playing around with an attempt to do some serial communication from
within R to a microcontroller board. I open a connection:
zz = file("/dev/ttyUSB0",open="a+") ## text mode
... when I execute
writeLines("0",con=zz)
I know the board receives the "0" because the board's serial comm LEDs light
up when submit the command at the R
2008 Sep 05
1
reading and parsing gzipped files
Hi all,I have large compressed text tab delimited files,
I am trying to write efficient function to read them,
I am using gzfile() and readLines()
zz <- gzfile("exampl.txt.gz", "r") # compressed file
system.time(temp1<-readLines(zz ))
close(zz)
which work fast, and create vector of strings.
The problem is to parse the result, if I use strsplit it takes longer
2010 Sep 16
3
funciones en R potencialmente peligrosas via web?
Hola:
Para el desarrollo del nuevo PluginR de Tiki (para poder ejecutar
scripts de R desde Tiki: en páginas Wiki, hojas de cálculo web, etc,
http://dev.tiki.org/PluginR ), por ahora estamos usando la lista de
funciones que se usaban en el proyecto r-php, y que fueran heredadas por
la extensión R de MediaWiki.
Como r-php se hizo hace algunos años (2006), me pregunto si alguien sabe
si hay
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",
2020 Jun 29
0
A warning in gzcon but not in gzfile
Hi all,
I used `gzfile` and `gzcon` to read a compressed file but I found that
`gzcon` gave me a different result than `gzfile`. It seems like the `gzcon`
does not handle the data correctly. I have posted an example below. In the
example, a portion of a compressed file is downloaded from Google Cloud as
a raw vector, and the data is saved into a temp file. If I use ` gzfile` to
read the file, it
2005 Sep 18
0
Updated rawConnection() patch
Here's an update of my rawConnection() implementation. In addition to
providing a raw version of textConnection(), this fixes two existing
issues with textConnection(): one is that the current textConnection()
implementation carries around unprotected SEXP pointers, the other is
a performance problem due to prolific copying of the output buffer as
output is accumulated line by line.
This new
2005 Jan 05
0
zlib
I need to decompress an array of bytes that were compressed using zlib. The
bytes are stored within a binary file. I can seek to the location, read the
length of the compressed byte array, and read the bytes into R. What I need
to do then is decompress the byte array to an array of doubles.
The code looks something like this:
compresslength = readBin(infile, integer(), 1, 4)
data =
2001 Dec 11
1
Using lib Rstreams and gzfile()
Hi all,
in the last time I've intensively used Rstreams to read and write from
binary files. Now I'm wondering if it is possible to use Rsteams
functions with gzipped files. But I haven't found the trick:
> p1c.gzip <- gzfile("daten/p1c_all.mea.gz", open="rb")
> readBin(p1c.gzip, integer(), n=64,size=2)
[1] 84 1 400 1 749 0 0 0
2009 Feb 08
1
compressing data without writing output to file
This might seem like a strange question but is there any way to compress an
R object (such as a matrix) and know its resulting size in bytes ?
Clearly, I could implement this in the following way (if x is my matrix):
zz <- gzfile(fname,"w");
write.table(x,zz);
close(zz);
file.info(fname)[,"size"];
However, I need to do this for hundreds of thousands
2006 Nov 09
2
Single precision data behaviour with readBin()
Hi all,
I am running R version 2.4.0 (2006-10-03) on an i686 pc with Mandrake
10.2 Linux. I was given a binary data file containing single precision
numbers that I would like to read into R. In a previous posting,
someone suggested reading in such data as double(), which is what I've
tried:
> zz <- file(file, "rb")
> h1 <- readBin(con = zz, what = double(), n = 1, size