Grokbase Groups R r-help June 2016
FAQ
I have written a following piece of code.?
binaryFile <- file("sampleBinary.dat", 'rb')>readBin(binaryFile, character(), endian="little")

I'm getting a warning message that says?


Warning message:?In readBin(binaryFile, chracter(), endian="little") : incomplete string at end of file has been discarded


I did research on this topic but was still unable to solve.


My file contains the following binary values:?01101000 01100101 01101100 01101100 01101111 00001010 which is hello in text. I just want to convert this into text.?


Any help would be appreciated.
  [[alternative HTML version deleted]]

Search Discussions

  • Jim Lemon at Jun 14, 2016 at 12:56 am
    Hi Fahman,
    That error message usually means that there is no newline at the end
    of the last line of the input file. Try adding a newline,


    Jim




    On Tue, Jun 14, 2016 at 1:17 AM, Fahman Khan via R-help
    wrote:
    I have written a following piece of code.
    binaryFile <- file("sampleBinary.dat", 'rb')>readBin(binaryFile, character(), endian="little")
    I'm getting a warning message that says

    Warning message: In readBin(binaryFile, chracter(), endian="little") : incomplete string at end of file has been discarded

    I did research on this topic but was still unable to solve.

    My file contains the following binary values: 01101000 01100101 01101100 01101100 01101111 00001010 which is hello in text. I just want to convert this into text.

    Any help would be appreciated.
    [[alternative HTML version deleted]]

    ______________________________________________
    R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
    https://stat.ethz.ch/mailman/listinfo/r-help
    PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
    and provide commented, minimal, self-contained, reproducible code.
  • Jeff Newmiller at Jun 14, 2016 at 4:05 am
    Please post in plain text format. Only you have the power to format your
    email the way we will see it... using the default HTML format only leads
    to odd wraparounds and weird characters that you don't know about when you
    send but we have to wade through when we recieve it.


    "Character" data is rather more complex now than it used to be in days of
    yore... what with Unicode UTF16 and UTF-8 and so on. You are getting into
    deep water trying to mix binary and text data. (I know enough to know I am
    no expert in this topic.) I highly recommend reading the article by Paul
    Murrell on reading binary data [1], but even that is unlikely to answer
    all the headaches you are diving into and it will probably stop being "on
    topic" for this list pretty quickly.


    One key point is that you should read "raw" data, not "character" data
    when getting data out of files, even if they are opened in "binary mode".


    [1] Viewing binary files with the hexview package. R News, 7(1):2--8,
    April 2007.


    On Mon, 13 Jun 2016, Fahman Khan via R-help wrote:

    I have written a following piece of code.?
    binaryFile <- file("sampleBinary.dat", 'rb')>readBin(binaryFile, character(), endian="little")
    I'm getting a warning message that says?

    Warning message:?In readBin(binaryFile, chracter(), endian="little") : incomplete string at end of file has been discarded

    I did research on this topic but was still unable to solve.

    My file contains the following binary values:?01101000 01100101 01101100 01101100 01101111 00001010 which is hello in text. I just want to convert this into text.?

    Any help would be appreciated.
    [[alternative HTML version deleted]]

    ______________________________________________
    R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
    https://stat.ethz.ch/mailman/listinfo/r-help
    PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
    and provide commented, minimal, self-contained, reproducible code.

    ---------------------------------------------------------------------------
    Jeff Newmiller The ..... ..... Go Live...
    DCN:<jdnewmil@dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go...
                                            Live: OO#.. Dead: OO#.. Playing
    Research Engineer (Solar/Batteries O.O#. #.O#. with
    /Software/Embedded Controllers) .OO#. .OO#. rocks...1k
    ---------------------------------------------------------------------------

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupr-help @
categoriesr
postedJun 13, '16 at 3:17p
activeJun 14, '16 at 4:05a
posts3
users3
websiter-project.org
irc#r

People

Translate

site design / logo © 2017 Grokbase