error openxlsx can only read .xlsx files When loading .xlsx files - r

I’m getting this error every time I load my excel files into R:
error openxlsx can only read .xlsx files
. However, all the files are .xlsx files and data looks like it loads ok. But as I’m new to R I'm not sure if I am safe to ignore this error and just treat it as a warning.
I have installed and loaded readxls & openxlsx libraries.

Related

How to read BUFR files in R

I am trying to read a BUFR binary in R for cyclone track forecasts.
Trying to read the file using rasters since that worked on GRIB files, but are not successful as the files are not recognized.

How to Read in xls file that requires permission to open in R

I have several xls files I need to read in and combine into one dataframe. I try
df <- readxl::read_excel("file.xls")
or
df <- readxl::read_xls("file.xls")
but neither works. I get the following error
Error:
filepath: /Users/.../.../file.xls
libxls error: Unable to open file
I believe the issue is that every time I open the file in Excel, I am asked if I trust this file before I can open it. Is there anyway around it?
I also am operating on a mac, and I want to avoid library(xlsx) or other packages that have Java dependencies.
UPDATE: I had the idea of just going into each file to click "Save As..." and change the format to xlsx instead of xls, but the default file format that showed was an Excel 2004 XML Spreadsheet (.xml). Does that suggest that my file is actually a xml file even though the extension in the name is .xls?

Convert xlsx file to csv file in R when xlsx file is present in hdfs

I want to know how can we convert .xlsx file residing in hdfs to .csv file using R script.
I tried using XLConnect and xlsx packages, but its giving me error 'file not found'.I am providing HDFS location as input in the R script using the above packages.I am able to read .csv files from hdfs using R script (read.csv()).
Do I need to install any new packages for reading .xlsx present in hdfs .
sharing the code i used:
library(XLConnect)
d1=readWorksheetFromFile(file='hadoop fs -cat hdfs://............../filename.xlsx', sheet=1)
"Error: FileNotFoundException (Java): File 'filename.xlsx' could not be found - you may specify to automatically create the file if not existing."
I am sure the file is present in the specified location.
Hope my question is clear. Please suggest a method to resolve it.
Thanks in Advance!
hadoop fs isn't a file, but a command that copies a file from HDFS to your local filesystem. Run this command from outside R (or from inside it using system), and then open the spreadsheet.

R Download.File Issue with Excel Workbook

I'm trying to download an Excel workbook using R's download.file function.
When I download the file manually (using Internet Explorer or Chrome, right click & save as) then the file downloads and I can then open it in Excel without any problems.
When I use download.file in R, the file downloads and reports the correct file size. However when I then try to open the downloaded xls file in Excel 2010 I get the following error message:
Excel found unreadable content in 'test.xls'. Do you want to recover the contents of this workbook? If you trust the source of this workbook, click Yes.
When I click Yes, nothing happens.
I've also tried accessing the file directly using the R package xlsx, this also fails.
You can try to download your file in binary mode (default for download.file is ASCII mode) with the mode argument. Something like :
download.file(myurl, mydestfile, mode="wb")

LinqToExcel External table is not in the expected format

I've been using LinqToExcel to parse an exel document for a while and suddenly it's stoped working.
I'm getting the following error:
External table is not in the expected format.
Any ideas why this is happening? Or how to fix?
if (File.Exists(filenameFull))
{
var excel = new ExcelQueryFactory(filenameFull);
IList<Row> scanningRangesRows =
excel.Worksheet("B - Scanning Ranges").ToList();
I was using version LinqToExcel 1.6.3, when the problem started happening I updated to the latest version LinqToExcel 1.6.6 to no avail.
I've just noticed that the file I'm downloading is significantly smaller than previous verisons. I opened it in notepad and I can see [Content_Types].xml amongst the binary data. So it appears that the data source is now being saved as an xml represention of the xls file with the same extension. When I open the same file manually in Excel it popup with
The file you are trying to open '', is in a different format
than specified by the file extension. Verify that the file is from a
trusted source before opening the file. Do you want to open the file
now?
On clicking yes the file still opens and looks the same as previous versions.
It's probably something to do with the file.
Maybe it's being saved as an .xlsx type of file. Can you try renaming the file extenstion to .xlsx and see if that works.

Resources