Re: [R] read.csv fails to read a CSV file from google docs

From: William Dunlap <wdunlap_at_tibco.com>
Date: Fri, 29 Apr 2011 11:13:56 -0700

> -----Original Message-----
> From: r-help-bounces_at_r-project.org
> [mailto:r-help-bounces_at_r-project.org] On Behalf Of David Winsemius
> Sent: Friday, April 29, 2011 10:36 AM
> To: Tal Galili
> Cc: r-help_at_r-project.org
> Subject: Re: [R] read.csv fails to read a CSV file from google docs
>
>
> 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&ke
> y=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

With S+ I get:
 S+>
download.file("http://spreadsheets0.google.com/spreadsheet/pub?hl=en&hl= en&key=0AgMhDTVek_sDdGI2YzY2R1ZESDlmZS1VYUxvblQ0REE&single=true&gid=0&ou tput=csv", destfile="e:/temp/splus")
 Problem in
download.file("http://spreadsheets0.google.com/spreadsheet/pu..: Could not get url: un
 supported protocol, libcurl was built with SSL disabled, https: not supported!
and with cygwin's wget I get
 E:\temp\jnk>wget
"http://spreadsheets0.google.com/spreadsheet/pub?hl=en&hl=en&key=0AgMhDT Vek_sDdGI2YzY2R1ZESDlmZS1VYUxvblQ0REE&single=true&gid=0&outpu t=csv"
 --2011-04-29 11:00:10--
http://spreadsheets0.google.com/spreadsheet/pub?hl=en&hl=en&key=0AgMhDTV ek_sDdGI2YzY2R1ZESDlmZS1VYUxvblQ0REE&single=true&gid= 0&output=csv
 Resolving spreadsheets0.google.com... 74.125.224.73, 74.125.224.71, 74.125.224.64, ...
 Connecting to spreadsheets0.google.com|74.125.224.73|:80... connected.  HTTP request sent, awaiting response... 302 Moved Temporarily  Location:
https://spreadsheets0.google.com/spreadsheet/pub?hl=en&hl=en&key=0AgMhDT Vek_sDdGI2YzY2R1ZESDlmZS1VYUxvblQ0REE&single=true&gid=0&output=csv [ following]
 --2011-04-29 11:00:11--
https://spreadsheets0.google.com/spreadsheet/pub?hl=en&hl=en&key=0AgMhDT Vek_sDdGI2YzY2R1ZESDlmZS1VYUxvblQ0REE&single=true&gid =0&output=csv
 Connecting to spreadsheets0.google.com|74.125.224.73|:443... connected.  ERROR: cannot verify spreadsheets0.google.com's certificate, issued by `/C=US/O=Google Inc/CN=Google Internet Authority':

   Unable to locally verify the issuer's authority.  To connect to spreadsheets0.google.com insecurely, use `--no-check-certificate'.
 Unable to establish SSL connection.

so I suspect that the SLL/certifcate business may also be the problem when
using R to get the document. The R error message is not very illuminating.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com

> >
> >
> > 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=tru
> e&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=tru
> e&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
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Fri 29 Apr 2011 - 18:17:46 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 29 Apr 2011 - 18:40:34 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive