使用R从Google驱动器下载文件 [英] download file from google drive using R

查看:166
本文介绍了使用R从Google驱动器下载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试过建议以读取Google驱动器中的csv文件.我点击该文件以获取可共享的文件链接.

I have tried the recommendations to read a csv file in google drive. I write click on the file to get the sharable file link.

我尝试了这4种方法中的每一种:(当我右键单击文件名时,我用ZZZZ代替了链接).

I have tried each of these 4 methods: (I have substituted ZZZZ for what I get as the link when I right-click on the file name).

x <- curl("https://drive.google.com/open?id=ZZZZ") data <- read.csv(x,skip=5,stringsAsFactors = F)

id <- "ZZZZ" data <- read.csv(sprintf("https://drive.google.com/open?id=%s&export=download",id),skip=5,stringsAsFactors = F)

data <- read.csv("https://drive.google.com/open?id=ZZZZ",skip=5,stringsAsFactors = F)

sURL <- sprintf("https://drive.google.com/open?id=%s&export=download",id) con <- curl(sURL); con2 <- read.csv(con,skip=5,stringsAsFactors = F)

推荐答案

有一个很棒的软件包"gsheet"(上帝保佑作者). 1.在Google云端硬盘中以Google表格的形式打开您的文件. 2.然后将您的文件公开(单击链接的任何人都可以使用). 3.然后在R中使用此代码:

There is a great package 'gsheet' (God bless the author). 1. Open your file in google drive as google sheet. 2. Then make your file public (available to anyone who clicks the link). 3. Then use this code in R:

install.packages('gsheet')  
library(gsheet) 
data <- gsheet2tbl('https://drive.google.com/open?id= COPY HERE YOUR ID LINK')

这篇关于使用R从Google驱动器下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆