问题
When I read in csv files from Dropbox into R
, I right-click the file and click share Dropbox link
. I then have a URL something like:
https://www.dropbox.com/blahhhhhhhhhh.csv?dl=0
So I change it to:
read.csv("http://dl.dropbox.com/blahhhhhhhhhh.csv?dl=0", ...)
and it works without the need to use any packages etc.
Is there a way to read files from OneDrive in a similar manner?
https://onedrive.live.com/blahhhhhhhhhhhhhhhhccsv
As when I try to read it into R
it doesn't give me the data frame I'm expecting from the file.
回答1:
I tested this with public OneDrive link:
- download the file
- get the URL in download page (Ctrl+J in Chrome):
[]
- paste the URL in read.csv("url...")
This works for me even when the public link changes.
回答2:
OneFlow gave me "embed" in the URL, so I changed it to "download" and got the resul
回答3:
None of those answers work for me, but I found an alternative solution that works.
- Find the file in OneDrive online using Chrome.
- Share it to anyone with the link.
- Right click the … and select “download”.
- Let the file download.
- Press Ctrl + J to open the Downloads page in Chrome.
- Find the link on that page for the file.
Use the following code to download the file.
read_url_csv <- function(url, ...){
tmpFile <- tempfile()
download.file(url, destfile = tmpFile)
url_csv <- readr::read_csv(tmpFile, ...)
return(url_csv)
}
onedrive_url <- "INSERT LINK COPIED ABOVE"
csv <- read_url_csv(onedrive)
回答4:
Reddit users recommend syncing One Drive files locally and reading the local files.
That worked for me.
- Have the person(s) who manage the shared location share the folder location with you. (It's possible sharing a file could work, but I haven't explored that. Folder location worked for me when testing, so that's what I recommend).
- Open the shared folder in One Drive
- Click "Sync"
You should now have the a local copy of those files stored on your PC and syncing online (just like Dropbox). You files will probably found in a sub-folder of this location:
C:\Users[Your user name]\
来源:https://stackoverflow.com/questions/29579782/reading-onedrive-files-to-r