【发布时间】:2021-08-20 20:28:38
【问题描述】:
我正在按照this 帖子中的说明将 2 个 csv 文件从我的谷歌驱动器下载到我的计算机。这是提供的代码-
library(googledrive)
library(purrr)
## store the URL you have
folder_url <- "https://drive.google.com/drive/folders/0B7tJg2i5HAo2c0VzVFVhLUdQcnM"
## identify this folder on Drive
## let googledrive know this is a file ID or URL, as opposed to file name
folder <- drive_get(as_id(folder_url))
## identify the csv files in that folder
csv_files <- drive_ls(folder, type = "csv")
## download them
walk(csv_files$id, ~ drive_download(as_id(.x)))
上述说明将 csv 文件下载到我的“文档”文件夹。我正在尝试将文件下载到我笔记本电脑上的特定文件夹,只需对最后一段代码进行轻微修改
walk(csv_files$id, ~ drive_download(as_id(.x),
path = "../Desktop/data_folder/,
overwrite = TRUE))
不幸的是,这会保存一个不包含任何数据且无法打开的 .xlsx 文件。如何更正代码以将两个文件保存到特定文件夹?
【问题讨论】: