Johannes Graumann
2009-May-11 11:05 UTC
[R] 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
jim holtman
2009-May-11 12:13 UTC
[R] readBin: read from defined offset TO defined offset?
Can you be more specific on how you want to "define the endpoint of that read". What is the criteria you want to use? Can you read in a block and then search of the pattern? On Mon, May 11, 2009 at 7:05 AM, Johannes Graumann <johannes_graumann@web.de> wrote:> 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 > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[alternative HTML version deleted]]
Duncan Murdoch
2009-May-11 13:07 UTC
[R] readBin: read from defined offset TO defined offset?
On 11/05/2009 7:05 AM, Johannes Graumann wrote:> 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?Sure: just use the "n" parameter to readBin. This will work for any type except character, but it doesn't make sense to read those in a given range: what do you do if the last one is not zero terminated? If you want the end of block to count as a terminator, then read the block as raw, add a null to the end, and then re-read the raw vector. Duncan Murdoch
Johannes Graumann
2009-May-15 18:41 UTC
[R] readBin: read from defined offset TO defined offset?
Thanks guys! Duncan's hints regarding "character" (which I was naturally using ;0) and the double "readBin" solved my problem - I'm extracting an index from a REALLY big XML file to get fast direct access to subsections, so that I only have to parse them rather than the whole thing (only SAX-style passing would be possible, since there's no way the thing will fit into memory). Thanks again, Joh Johannes Graumann wrote:> 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