[R] Creating file from raw content

jim holtman jho|tm@n @end|ng |rom gm@||@com
Mon Jun 1 17:34:36 CEST 2020


You can read it in as 'raw'

============
input <- file('your.xlsx', open = 'rb')  # open as binary
excel_file <- readBin(input, raw(), 1e8)  # make sure you read in all the file
close(input)

output <- file('your_new.xlsx', 'wb')
writeBin(excel_file, output)
close(output)
===================


Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.


Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.


On Fri, May 29, 2020 at 12:12 PM Sebastien Bihorel via R-help
<r-help using r-project.org> wrote:
>
> Hi,
>
> Let's say I can extract the content of an Excel .xlsx file stored in a database and store it as raw content in an R object. What would be the proper way to "create" a .xlsx file and "transfer" the content of this obj into it? I took the example of an Excel file, but my question would extend to any kind of binary file.
>
> Thank you in advance for your input
>
> Sebastien
> ______________________________________________
> R-help using 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.



More information about the R-help mailing list