ireadBin {iterors} | R Documentation |
Create an iterator to read binary data from a connection
Description
Create an iterator to read binary data from a connection.
Usage
ireadBin(
con,
what = "raw",
n = 1L,
size = NA_integer_,
signed = TRUE,
endian = .Platform$endian,
ipos = NULL
)
Arguments
con |
A connection object or a character string naming a file or a raw vector. |
what |
Either an object whose mode will give the mode of the vector to
be read, or a character vector of length one describing the mode: one of
“numeric”, “double”, “integer”, “int”,
“logical”, “complex”, “character”, “raw”.
Unlike |
n |
integer. The (maximal) number of records to be read each time the iterator is called. |
size |
integer. The number of bytes per element in the byte stream. The default, ‘NA_integer_’, uses the natural size. |
signed |
logical. Only used for integers of sizes 1 and 2, when it determines if the quantity on file should be regarded as a signed or unsigned integer. |
endian |
The endian-ness ('“big”' or '“little”') of the target system for the file. Using '“swap”' will force swapping endian-ness. |
ipos |
iterable. If not |
Details
Originally from the itertools
package.
Value
An iteror reading binary chunks from the connection.
Examples
zz <- file("testbin", "wb")
writeBin(1:100, zz)
close(zz)
it <- ihasNext(ireadBin("testbin", integer(), 10))
repeat print(nextOr(it, break))
unlink("testbin")