Message-ID: <9F4CD0FB-F635-4979-809E-F66519C49DB8@comcast.net>
Date: 2011-04-29T17:36:04Z
From: David Winsemius
Subject: read.csv fails to read a CSV file from google docs
In-Reply-To: <BANLkTimTkvK-EUxYTPMxN+FvQhG8NmgenA@mail.gmail.com>
On Apr 29, 2011, at 11:19 AM, Tal Galili wrote:
> Hello all,
> I wish to use read.csv to read a google doc spreadsheet.
>
> I try using the following code:
>
> data_url <- "
> http://spreadsheets0.google.com/spreadsheet/pub?hl=en&hl=en&key=0AgMhDTVek_sDdGI2YzY2R1ZESDlmZS1VYUxvblQ0REE&single=true&gid=0&output=csv
> "
> read.csv(data_url)
>
> Which results in the following error:
>
> Error in file(file, "rt") : cannot open the connection
>
>
> I'm on windows 7. And the code was tried on R 2.12 and 2.13
>
> I remember trying this a few months ago and it worked fine.
I am always amused at such claims. Occasionally they are correct, but
more often a crucial step has been omitted. In this case you have at a
minimum embedded line-feeds in your URL string and have not
established a connection, so it could not possibly have succeeded as
presented.
But now it's time to admit I do not know why it is not succeeding when
I correct those flaws.
> closeAllConnections()
> data_url <- url("http://spreadsheets0.google.com/spreadsheet/pub?hl=en&hl=en&key=0AgMhDTVek_sDdGI2YzY2R1ZESDlmZS1VYUxvblQ0REE&single=true&gid=0&output=csv
")
> read.csv(data_url)
Error in open.connection(file, "rt") : cannot open the connection
> closeAllConnections()
> dd <- read.csv(con <- url("http://spreadsheets0.google.com/spreadsheet/pub?hl=en&hl=en&key=0AgMhDTVek_sDdGI2YzY2R1ZESDlmZS1VYUxvblQ0REE&single=true&gid=0&output=csv
"))
Error in open.connection(file, "rt") : cannot open the connection
So, I guess I'm not reading the help pages for `url` and `read.csv` as
well I thought I was.
> Any suggestion what might be causing this or how to solve it?
--
David Winsemius, MD
West Hartford, CT