Error reading .xls file with format_from_signature NA in R - r

I have a .xls file which is sent to me daily and I'd like to automate the handling I do with it through R.
When I try to read the file using read_xls, it throws the following error libxls error: Unable to open file. For anyone with knowledge of Excel, this is one of those files that, when you try to open it there, Excel warns you about it not matching the file format and the extension. This, along with the fact that using format_from_signature on the file returns NA, tells me that the file isn't a real .xls file but rather a forced .xls document.
I can fix the issue for a single file by just opening it on Excel and saving it as a normal .xlsx, the problem is doing it frequently. I would like to replicate that process but all in R to automate it.
Edit: I've added an Excel file that meets the criteria I'm describing.

Related

Open a .zip or .7zip file in R without upacking it to the hard drive

I have .zip and .7zip files (.csv) that are encrypted that I want to read in R without unzipping the data. I know I can open such files if they are not encrypted without unzipping them first, R Reading in a zip data file without unzipping it, but in this case the files are encrypted. Do you know how I can decrypt them and load them into R without unzipping them?
It should be said that I only need a solution for one of the file formats if there is only a solution for one of them.

Why is read_excel very slow while the excel file to read from R is also opened in the Excel?

The environment is:
R: 3.6.1
readxl version: ‘1.3.1’
When I close the Excel program, read_excel takes a second or 2, but when I have the file opened in Excel, then read_excel in R can take a few minutes.
I wonder why was that?
Some programs, like Excel, put access restrictions on files while the files are open. This prevents accidental conflicts from external changes to the same file while it is open.
I don't know why specifically it would affect other tools from reading the file and why the effect would manifest as slower speed instead of complete inability. Maybe Excel is trying to monitor the access to the file and compare it to the content it has loaded.

Using R to change the extension of all files in a folder

I have a folder with a huge amount of old .xls files. I would like R to turn the whole folder (change the extension) into .csv or .xlsx files to subsequently load them into r.
I have been using R for a while, but never like this, so I do not really have an idea where to start.

How to load the actual .RData file, that is just called .RData (the compressed file that gets saved from a session)

Similar questions, but not the question I have, were around loading a file that someone saved as somefilename.RData. I am trying to do something different.
What I am trying to do is load the actual .RData file that gets saved from an R session. The context is that I am using 2 different computers and am trying to download the .RData file from one computer and then load this same .RData file on a different computer in RStudio.
When I download the .RData file it shows up without the “.” (e.g., it shows up as RData). When I try to rename it “.RData”, Windows will not allow me to do so.
Is there a way to do what I am trying to do?
Thanks!
After playing around with this, I was able to load the file (even though it was called “RData“ and not called “.RData”, by using RStudio by going to Session > Load Workspace... and then navigating to that file. I had used File > Open File... which did not work

csv files in opencpu

If I put a very small csv file in my GitHub directory so that it gets copied to /ocpu/github/username/projectname/www/ , will I be able to access the contents of the csv for use in a R function? I tried to ajax the file, but I get a 404 error even though I can see the csv file sitting in the www directory of my local server. I need to have the csv on the server as a static file rather than being uploaded by a function. Thanks
You should be able to access them like any other file. Can you post an example that shows what you are doing and what error you are getting?
That said, if you just want to use this data in your R functions, it is better to include it in the R package as an actual data file. Also see section 1.1.6 of Writing R Extensions. An example is the mapapp package, which includes a dataset called countryExData. Also see the live app.

Resources