I’m seeking a way to connect a “.xlsx” file from a shared OneDrive link. The OneDrive where the file is stocked is not mine but I’ve full access to the .xlsx file. My code:
<code>library(curl)
library(readxl)
url <- "https://onedrive.live.com/:x:/g/personal/D7F26BE16D487B10/EYJxLYphlkRFogUmL7LhO4QBEym63JCSoZVQXXgeXG6ptA?resid=D7F26BE16D487B10!s8a2d718296614544a205262fb2e13b84&ithint=file%2Cxlsx&e=Oj2gQq&migratedtospo=true&redeem=aHR0cHM6Ly8xZHJ2Lm1zL3gvYy9kN2YyNmJlMTZkNDg3YjEwL0VZSnhMWXBobGtSRm9nVW1MN0xoTzRRQkV5bTYzSkNTb1pWUVhYZ2VYRzZwdEE_ZT1PajJnUXE"
temp_file <- tempfile(fileext = ".xlsx")
browseURL(url)
curl_download(url, temp_file)
data <- read_excel(temp_file)
head(data)
</code>
<code>library(curl)
library(readxl)
url <- "https://onedrive.live.com/:x:/g/personal/D7F26BE16D487B10/EYJxLYphlkRFogUmL7LhO4QBEym63JCSoZVQXXgeXG6ptA?resid=D7F26BE16D487B10!s8a2d718296614544a205262fb2e13b84&ithint=file%2Cxlsx&e=Oj2gQq&migratedtospo=true&redeem=aHR0cHM6Ly8xZHJ2Lm1zL3gvYy9kN2YyNmJlMTZkNDg3YjEwL0VZSnhMWXBobGtSRm9nVW1MN0xoTzRRQkV5bTYzSkNTb1pWUVhYZ2VYRzZwdEE_ZT1PajJnUXE"
temp_file <- tempfile(fileext = ".xlsx")
browseURL(url)
curl_download(url, temp_file)
data <- read_excel(temp_file)
head(data)
</code>
library(curl)
library(readxl)
url <- "https://onedrive.live.com/:x:/g/personal/D7F26BE16D487B10/EYJxLYphlkRFogUmL7LhO4QBEym63JCSoZVQXXgeXG6ptA?resid=D7F26BE16D487B10!s8a2d718296614544a205262fb2e13b84&ithint=file%2Cxlsx&e=Oj2gQq&migratedtospo=true&redeem=aHR0cHM6Ly8xZHJ2Lm1zL3gvYy9kN2YyNmJlMTZkNDg3YjEwL0VZSnhMWXBobGtSRm9nVW1MN0xoTzRRQkV5bTYzSkNTb1pWUVhYZ2VYRzZwdEE_ZT1PajJnUXE"
temp_file <- tempfile(fileext = ".xlsx")
browseURL(url)
curl_download(url, temp_file)
data <- read_excel(temp_file)
head(data)
and my error message:
<code>Error in utils::unzip(zip_path, list = TRUE) :
zip file 'C:UsersLa MachineAppDataLocalTempRtmpYBemJUfile44dc762e4fef.xlsx' cannot be opened
</code>
<code>Error in utils::unzip(zip_path, list = TRUE) :
zip file 'C:UsersLa MachineAppDataLocalTempRtmpYBemJUfile44dc762e4fef.xlsx' cannot be opened
</code>
Error in utils::unzip(zip_path, list = TRUE) :
zip file 'C:UsersLa MachineAppDataLocalTempRtmpYBemJUfile44dc762e4fef.xlsx' cannot be opened
I tried the methods reported in this post: Reading OneDrive files to R
I tried:
- Download the file
and get the URL in download page (Ctrl+J in Chrome) but don’t have the same URL format as seen in the related post. - The curl package which seems OK. But I’ve this error concerning zip file. In my environment the file is “.xlsx” but when I tried to open it in Excel the file wasn’t recognized. I also try zip package to unzip it. But because of the “.xlsx”, it didn’t work. The file should be “.zip” I think?
In fine I want to download the file into R, work on it, and export it again to OneDrive
Any ideas please?
2