[R] Download a file from url

Henrik Bengtsson hb at biostat.ucsf.edu
Tue Oct 16 18:33:48 CEST 2012


Have you tried downloading it manually using a web browser or similar?
 If so, compare that downloaded file to that you get from
download.file() and see if they're the same.  If the same, the problem
is elsewhere (which is not unlikely to be the case). /H

On Mon, Oct 15, 2012 at 6:15 PM, veepsirtt <veepsirtt at gmail.com> wrote:
> Hi Henrik,
> i included the mode='wb' but gives me this error.
> What is the other method to download the excel file?.
> With kind regards
> veepsirtt
>
>
> library(XLConnect)
>>
>> url = "http://www.nseindia.com/content/fo/fii_stats_12-Oct-2012.xls"
>> local.xls.file = tempfile()
>>
>> download.file(url, local.xls.file, method='wget', mode='wb',extra="-U
> 'Mozilla/5.0 (X11; Linux) Gecko Firefox/5.0'")
> Warning message:
> In download.file(url, local.xls.file, method = "wget", mode = "wb",  :
>   download had nonzero exit status
>> wb = loadWorkbook(local.xls.file, create=F)
> Error: FileNotFoundException (Java): File 'filed0c141444d8' could not be
> found - you may specify to automatically create the file if not existing.
>> data = readWorksheet(wb, sheet=1)
> Error in readWorksheet(wb, sheet = 1) :
>   error in evaluating the argument 'object' in selecting a method for
> function 'readWorksheet': Error: object 'wb' not found
>>
>
>
> On Mon, Oct 15, 2012 at 11:58 PM, Henrik Bengtsson-3 [via R] <
> ml-node+s789695n4646268h88 at n4.nabble.com> wrote:
>
>> You didn't say what errors you've got but you probably wants to
>> specify argument mode="wb" in your download.file() call, cf.
>> https://stat.ethz.ch/pipermail/r-devel/2012-August/064739.html
>>
>> /Henrik
>>
>>
>> On Mon, Oct 15, 2012 at 1:57 AM, veepsirtt <[hidden email]<http://user/SendEmail.jtp?type=node&node=4646268&i=0>>
>> wrote:
>>
>> > Hi
>> >
>> > Download the xls file from this link
>> > http://www.nseindia.com/content/fo/fii_stats_12-Oct-2012.xls
>> > <http://www.nseindia.com/content/fo/fii_stats_12-Oct-2012.xls>
>> >
>> > I tried this
>> > ---------------------------------------------------------------
>> >  library(XLConnect)
>> > url = "http://www.nseindia.com/content/fo/fii_stats_12-Oct-2012.xls"
>> > local.xls.file = tempfile()
>> > download.file(url, local.xls.file)
>> > wb = loadWorkbook(local.xls.file, create=F)
>> > data = readWorksheet(wb, sheet=1)
>> > View(data)
>> > ---------------------------------------------------------------
>> > no results ...
>> > kindly help me
>> > thanks
>> > veepsirtt
>> >
>> >
>> >
>> >
>> > --
>> > View this message in context:
>> http://r.789695.n4.nabble.com/Download-a-file-from-url-tp4642985p4646215.html
>> > Sent from the R help mailing list archive at Nabble.com.
>> >
>> > ______________________________________________
>> > [hidden email] <http://user/SendEmail.jtp?type=node&node=4646268&i=1>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.
>>
>> ______________________________________________
>> [hidden email] <http://user/SendEmail.jtp?type=node&node=4646268&i=2>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.
>>
>>
>> ------------------------------
>>  If you reply to this email, your message will be added to the discussion
>> below:
>>
>> http://r.789695.n4.nabble.com/Download-a-file-from-url-tp4642985p4646268.html
>>  To unsubscribe from Download a file from url, click here<http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4642985&code=dmVlcHNpcnR0QGdtYWlsLmNvbXw0NjQyOTg1fDY5NzkzMTE3Nw==>
>> .
>> NAML<http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>>
>
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Download-a-file-from-url-tp4642985p4646295.html
> Sent from the R help mailing list archive at Nabble.com.
>         [[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