I'm using a microsoft app (from http://portal.office.com) to translate and stock tweet on an online excel sheet, now I want to read it with R.
The data in excel sheet url https://myagency-my.sharepoint.com/.../tweet.xlsx
I tried:
library(readxl)
read_excel('//companySharepointSite/project/.../ExcelFilename.xlsx', Sheet1', skip=1)`
from this post. It gives:
Error in sheets_fun(path) : Evaluation error: zip file
I believe read_excel works only with local files. This might do the trick:
library(xlsx)
library(httr)
url <- 'https://myagency-my.sharepoint.com/.../tweet.xlsx'
GET(url, write_disk("excel.xlsx", overwrite=TRUE))
frmData <- read.xlsx("excel.xlsx", sheetIndex=1, header=TRUE)
Related
I am trying to download data from url
https://migration.iom.int/datasets/europe-%E2%80%94-mixed-migration-flows-europe-quarterly-overview-april-june-2021
On this page is available dataset with file into Excel and link for downloading data is https://migration.iom.int/system/tdf/datasets/Q2%202021%20Mixed%20Migration%20Flows%20to%20Europe%20%28April%20-%20June%202021%29.xlsx?file=1&type=node&id=12261
So I want to download all this data in Excel format directly into R.
library(rvest)
URL <- "https://migration.iom.int/system/tdf/datasets/Q2%202021%20Mixed%20Migration%20Flows%20to%20Europe%20%28April%20-%20June%202021%29.xlsx?file=1&type=node&id=12261"
pg <- read_html(URL)
html_attr(html_nodes(pg, "download"), "href")
But I made some mistake and I don't make download. So can anybody help me how to download this data into R .
I personally would go about it in the following way.
Download the data into a specified destination, read the excel file from that location. An idea would be:
download.file(url, destinationFile)
fileInR <- read.table(file = desinationFile,sep = â\tâ)
However, a simple google search for both (downloading and reading in an excel file in R) should provide you with plenty more options.
I have a secure Url which provides data in Excel format. How do I read it in R studio?
Please mention the necessary package and functions. I have tried read.xls(),
read_xlsx, read.URL and some more. Nothing seems to work.
You can do it in two steps. First, you'll need to download it with something like download.file, then read it with readxl::read_excel
download.file("https://file-examples.com/wp-content/uploads/2017/02/file_example_XLS_10.xls", destfile = "/tmp/file.xls")
readxl::read_excel("/tmp/file.xls")
library(readxl)
library(httr)
url<-'https://......xls'
GET(url, write_disk(TF <- tempfile(fileext = ".xls")))
read_excel(TF)
Have you tried importing it as a .csv dataset into RStudio? Might be worth a try!:)
This question already has answers here:
Downloading Excel File Using R
(3 answers)
Closed 4 years ago.
The following code
library(readxl)
url <- "http://www.econ.yale.edu/~shiller/data/ie_data.xls"
destfile <- "ie_data.xls"
download.file(url, destfile)
ie_data <- read_xls(destfile, sheet="Data", skip = 7)
produces Error in sheets_fun(path) : Failed to open ie_data.xls
One thing that perplexes me is that if goto the URL and download the file manually I can use read_xls to open it. I think the issue may be with download.file function.
I'd like to be able to read this Excel file directly from the URL or at least download it and read it without doing so manually. I'm on a Window x86_64 system using R 3.5.1 and readxl version 1.1.0. Thanks.
I still don't know why the code above doesn't work. Using this SO post, I find that the following code will work:
library(httr)
library(readxl)
url <- "http://www.econ.yale.edu/~shiller/data/ie_data.xls"
GET(url, write_disk(tf <- tempfile(fileext = ".xls")))
ie_data <- read_excel(tf, sheet="Data", skip = 7)
Because you are using windows you have to specify binary mode
download.file(url, destfile, mode="wb")
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.
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")
I'm interested in importing directly in R a portion of the .xls associated with the following url. The .xls has two different spreadsheets. I want to import the table that starts in the 5th row in the second spreadsheets. An attempt is the following:
require(gdata)
url = "https://www.philadelphiafed.org/-/media/research-and-data/real-time-center/real-time-data/data-files/files/routput_first_second_third.xls?la=en.xls"
dataset = read.xls(url, sheet=2, header=T, skip=4)
The error that I get is:
Error in file.exists(tfn) : invalid 'file' argument
I'm working in Windows. The source of the .xls is here under the name "All available observations". You are very welcome use different packages.
First step is to download file then you can read it.
require(gdata)
url = "https://www.philadelphiafed.org/-/media/research-and-data/real-time-center/real-time-data/data-files/files/routput_first_second_third.xls?la=en.xls"
download.file(url, destfile="file.xls")
data<- read.xls("file.xls", header=TRUE, pattern="Rank", header=TRUE, sheet=2, skip=3)