Home » excel » excel – R read_excel from online web page link produces an empty data frame

excel – R read_excel from online web page link produces an empty data frame

Posted by: admin May 14, 2020 Leave a comment

Questions:

Hi this is my first time posting,
I am trying to obtain data from an online web page link excel sheet. However,it works for the other links on the page but not a specific one which returns a blank data frame.

library(readxl)

download.file("https://www.parismou.org/sites/default/files/2016-04-DetentionLists_0.XLS","test.xls",mode="wb")
tbls=read_excel("test.xls")

Downloading it as a .xls file works fine but reading it doesnt work.
I have also tried using:

tbls=read.table("https://www.parismou.org/sites/default/files/2016-04-DetentionLists_0.XLS", header=TRUE, skipNul= TRUE) 

which returns:

Error in read.table("https://www.parismou.org/sites/default/files/2016-04-DetentionLists_0.XLS",  : 
  no lines available in input

I have also tried the XLConnect packages but those returned the following error:

require(XLConnect)
download.file("https://www.parismou.org/sites/default/files/2016-04-DetentionLists_0.XLS","test.xls",mode="wb")
tblspx=loadWorkbook("test.xls")

Error: OldExcelFormatException (Java): The supplied spreadsheet seems to be Excel 5.0/7.0 (BIFF5) format. POI only supports BIFF8 format (from Excel versions 97/2000/XP/2003)

Any help would be greatly appreciated.

How to&Answers:

You’re dealing with a very old excel format. The gdata package can deal with that (see this SO post):

install.packages("gdata")
require(readxl)

download.file("https://www.parismou.org/sites/default/files/2016-04-DetentionLists_0.XLS","test.xls",mode="wb")

tbls = gdata::read.xls("test.xls", fileEncoding="latin1")