[英]Identifying list of xlsx files from the cloud (google drive)
I am trying to create a loop where I can perform the same set of functions for a bunch of files. 我试图创建一个循环,在其中可以对一堆文件执行相同的功能集。 However, the files are stored on a shared folder in google drive (xlsx files) and I can't seem to get the code to "find them". 但是,这些文件存储在Google驱动器的共享文件夹中(xlsx文件),我似乎无法获得“查找它们”的代码。 I am working on a Mac (if that makes a difference). 我正在Mac上工作(如果有帮助)。
Here is an example of what I have tried: 这是我尝试过的一个示例:
library("googledrive")
library("readxl")
library("curl")
library("googlesheets")
library("xlsx") # and a few more which I have tried!
> setwd("/Users/xxx/Documents/R") #working on a Mac
> WS.URL <- "https://drive.google.com/drive/u/0/folders/xxx" # this is the shared
drive folder containing numerous xlsx files
##a - the main one I am trying to do ###
> list.files(path = "WS.URL")
character(0) ## there are about 10 files in this folder which aren't showing up. I can't create a loop if I can't retrieve the files.
#b
> nfiles <-length(WS)
> nfiles
[1] 1 # should be about 10
#c
dest <- ("/Users/xxx/Documents/R")
try(download.file("WS.URL", dest))
I have no idea if I am missing something really obvious, still getting to grips with R. Surely this should be straightforward? 我不知道我是否遗漏了一些确实很明显的东西,但仍然想与R保持联系。这肯定很简单吗?
HELP! 救命!
I cant help much with R but there is a parameter on file.list method called q its used for searching 我对R的帮助不大,但是file.list方法上有一个名为q的参数,用于搜索
GET https://www.googleapis.com/drive/v3/files?q=sharedWithMe GET https://www.googleapis.com/drive/v3/files?q=sharedWithMe
by return sending q=sharedWithMe
it should return all the files that are shared with you. 通过返回发送q=sharedWithMe
它应该返回与您共享的所有文件。 Testing the q method is easer using the Google APIs exploerer you might want to test it here 使用您可能要在此处进行测试的Google API开发工具,可以更轻松地测试q方法
Note as far as i know https://drive.google.com/drive/u/0/folders/xxx
is not the proper end point for the google drive api which may be causing some of your issues. 请注意,据我所知, https://drive.google.com/drive/u/0/folders/xxx
不是适用于google驱动器api的正确端点,这可能会导致您的某些问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.