[R] Help with Download of a comma separated file in zip format

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Tue Jul 15 19:31:49 CEST 2014


Circumventing content protection measures or picky server configurations such as this appears to be tends to involve HTTP protocol details that are off topic here, though someone may tackle your problem anyway and report back. Once you know what your protocol needs are (perhaps with the help of the Firebug Firefox developer tools) and have read the R documentation for the functions and packages you are using, asking for clarification on the documentation would be fair game here.

I tried setting the HTTPUserAgent string using the options function [1] but that didn't help.

Oh, and please read the Posting Guide mentioned at the bottom of all R-help posts, which points out that you should send plain text emails to this list. HTML is a what-you-see-is-not-necessarily-what-we-see format.

[1] https://stat.ethz.ch/pipermail/r-help/2007-November/145811.html
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

On July 15, 2014 8:24:01 AM PDT, Electron Musketeer <musketeere at gmail.com> wrote:
>Dear Experts
>
>I am new to this forum and to R and was trying the following to access
>a
>zip file from  the webpages of the NSE. Here is my code.
>
>temp <- tempfile()
>download.file("
>http://www.nseindia.com/content/historical/DERIVATIVES/2014/JUL/fo09JUL2014bhav.csv.zip
>",temp)
>con <- unz(temp, "a1.dat")
>data <- matrix(scan(con),ncol=4,byrow=TRUE)
>unlink(temp)
>
>
>The result is:
>cannot open URL '
>http://www.nseindia.com/content/historical/DERIVATIVES/2014/JUL/fo09JUL2014bhav.csv.zip
>'
>In addition: Warning message:
>In download.file("
>http://www.nseindia.com/content/historical/DERIVATIVES/2014/JUL/fo09JUL2014bhav.csv.zip",
> :
>  cannot open: HTTP status was '403 Forbidden'
>
>
>I tried accessing this file directly from the website and it is letting
>me
>access it. My question is why is it not letting me download from R? I
>have
>gone through some websites to see if this has been resolved but the
>older
>resolutions also do not work. Can someone help please?
>
>Thx
>Balaji
>
>	[[alternative HTML version deleted]]
>
>______________________________________________
>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.



More information about the R-help mailing list