Accessing A Public Google Sheet

烂漫一生 提交于 2019-12-08 04:16:01

问题


I've done a fair amount of research around this topic and none of the answers I've found on SO or through the Google have worked.

I'm trying with R to access a public google doc that I don't believe has been published to the web. I would like to be able to access the data contained in the doc in an API-like way so that I could make a dashboard off of it. I've emailed the owner of the data to hopefully get the document published but in the interim, and as an exercise for the future, does anyone know how to access a public document that isn't published?

To that end I've created a dummy google doc that's public but not published at the following link. It should have 2 columns and 3 rows.

https://docs.google.com/spreadsheets/d/1z2hDygMzRG_yN5JBFVwGr4aci87AHSg1M7qvVu-uv_s/edit?usp=sharing

Any help is much appreciated. Thanks.


回答1:


Try this

url <- "https://docs.google.com/spreadsheets/d/1z2hDygMzRG_yN5JBFVwGr4aci87AHSg1M7qvVu-uv_s/export?format=csv&id=1z2hDygMzRG_yN5JBFVwGr4aci87AHSg1M7qvVu-uv_s&gid=0"
(df <- read.csv(url))
#   col1 col2
# 1    a    1
# 2    b    2
# 3    c    3


来源:https://stackoverflow.com/questions/25511004/accessing-a-public-google-sheet

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!