使用R下载Excel文件 [英] Downloading Excel File Using R

查看:92
本文介绍了使用R下载Excel文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从哥伦比亚中央银行的网站下载Excel文件,但似乎通常的download.file函数无法完成工作.

I am trying to download an Excel file from Central bank of Colombia website, but it seems that the usual download.file function couldn't do the job.

例如,我尝试下载此页面上的第一个文件"Serie Historica": http://www.banrep.gov.co/es/indice-tasa-cambio-real

For example, I am trying to download the first file "Serie historica" on this page: http://www.banrep.gov.co/es/indice-tasa-cambio-real

文件的链接如下,我在download.file函数中使用了该链接

The link to the file is as follows, which I used in the download.file function http://obieebr.banrep.gov.co/analytics/saw.dll?Download&Format=excel2007&Extension=.xls&BypassCache=true&path=%2Fshared%2FSeries%20Estad%c3%adsticas_T%2F1.%20Indice%20de%20Tasa%20de%20Cambio%20Real%2F1.1.%20Serie%20historica_IQY&SyncOperation=1&NQUser=publico&NQPassword=publico

我使用的命令是: download.file(文件路径,destfile,安静= FALSE,mode ="wb")

The command I used is: download.file(filepath, destfile, quiet=FALSE, mode="wb")

任何帮助将不胜感激!

推荐答案

我希望这个示例能指导您

I hope this example will guide you

library(readxl)
library(httr)
url1<-'https://evs.nci.nih.gov/ftp1/CDISC/SDTM/SDTM%20Terminology.xls'
GET(url1, write_disk(tf <- tempfile(fileext = ".xls")))
df <- read_excel(tf, 2L)
str(df)

如果您可以下载文件,则可以按以下方式阅读

If you can download the file you could read it as follows

library(readxl)
datos <- read_xlsx("C:/Users/USER/Downloads/1.1. Serie historica_IQY.xlsx", skip = 8, n_max = 369)

这篇关于使用R下载Excel文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆