1

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.

n8sty
  • 1,418
  • 1
  • 14
  • 26

1 Answers1

4

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
lukeA
  • 53,097
  • 5
  • 97
  • 100
  • So this definitely works and I'm kind-of ashamed now since the answer is obvious. Problem is, the question I asked doesn't seem to mirror the real world problem I'm trying to solve. – n8sty Aug 26 '14 at 18:10
  • I figured out what I did wrong. I had the sheet published as a csv. The sheet I'm trying to get to isn't published. In case anyone's feeling particularly generous the correct url is: https://docs.google.com/spreadsheets/d/1z2hDygMzRG_yN5JBFVwGr4aci87AHSg1M7qvVu-uv_s/edit?usp=sharing. – n8sty Aug 26 '14 at 18:13
  • And to bring everything full circle . . . it works if I change the url in the last comment to: 'https://docs.google.com/spreadsheets/d/1cEGQ3eAFKpFBVq1k2mZIy5mBPxC6nBTJHzuSWtZQSVw/export?usp=sharing&format=csv' – n8sty Aug 26 '14 at 18:20