« useR! 2014 conference update | Main | A million new R users »

June 03, 2014

Comments

Feed You can follow this conversation by subscribing to the comment feed for this post.

You can actually force googledocs to give you a csv, the option is just not in the menus.

https://docs.google.com/spreadsheets/d/KEY/export?format=csv&id=KEY

inserting your unique key inplace of 'KEY'. You can then just pull it into R with RCurl:

require(RCurl)

url <- https://docs.google.com/spreadsheets/d/KEY/export?format=csv&id=KEY

myCsv <- getURL(url,.opts=list(ssl.verifypeer=FALSE))
test <- read.csv(textConnection(myCsv))

Good alternative method though. Especially as I haven't figured out how to tab through multiple sheets within a single document.

Hi, Jack

Yes, I'm aware of this method. But this also seemed to have changed with the new version of Google Spreadsheets.

I tried this with my URL:

url <- "https://docs.google.com/spreadsheets/d/1MQ50_tn76GqQAOpFigcHms4zFqkoM_JS4sOittv_vgA/export?format=csv&id=KEY"

myCsv <- getURL(url,.opts=list(ssl.verifypeer=FALSE))
test <- read.csv(textConnection(myCsv))
test

The result is not a useful data frame:

X.HTML.
1
2 Moved Temporarily
3
4
5 Moved Temporarily
6 The document has moved here.
7
8

If you find a way of fixing this, I'd be most interested!

Andrie

not working as mentioned please help.
Satish

Hi Andrie,

Interesting. Did you include your KEY in the URL twice?? (I noticed your URL still has the words KEY in it at the end). For some reason you need to include the key twice. I've just tried it on my system and it is working, and producing a useable data frame.

url <- "https://docs.google.com/spreadsheets/d/1MQ50_tn76GqQAOpFigcHms4zFqkoM_JS4sOittv_vgA/export?format=csv&id=1MQ50_tn76GqQAOpFigcHms4zFqkoM_JS4sOittv_vgA"

Your method is much slicker though!!
Jack

The comments to this entry are closed.

Search Revolutions Blog




Got comments or suggestions for the blog editor?
Email David Smith.
Follow revodavid on Twitter Follow David on Twitter: @revodavid
Get this blog via email with Blogtrottr