讀XLS

2017-08-11 64 views
1

我的工作我公司的研發工作室的服務器上,並想訪問的ONS website讀XLS

公佈的數據,我寫的是建立正確的URL的幾行,但我阻止時試圖從URL

這裏讀取該文件是一個簡單的例子(即URL硬編碼):

library(gdata) 
currUrl <- "http://www.ons.gov.uk/file?uri=/peoplepopulationandcommunity/birthsdeathsandmarriages/deaths/datasets/weeklyprovisionalfiguresondeathsregisteredinenglandandwales/2017/publishedweek302017.xls" 
data <- read.xls(currUrl) 

我得到以下錯誤:

> ERROR: The certificate of www.ons.gov.uk' is not trusted. ERROR: The 
> certificate of www.ons.gov.uk' hasn't got a known issuer. Error 
> parsing file '/tmp/RtmpXou27y/file386f520067bd.xls'. Error in 
> xls2sep(xls, sheet, verbose = verbose, ..., method = method, : 
> Intermediate file '/tmp/RtmpXou27y/file386f4e7dd580.csv' missing! In 
> addition: Warning messages: 1: In download.file(xls, tf, mode = "wb") 
> : download had nonzero exit status 2: running command 
> ''/usr/bin/perl' 
> '/home/nr/R/x86_64-pc-linux-gnu-library/3.2/gdata/perl/xls2csv.pl' 
> '/tmp/RtmpXou27y/file386f520067bd.xls' 
> '/tmp/RtmpXou27y/file386f4e7dd580.csv' '1'' had status 255 Error in 
> file.exists(tfn) : invalid 'file' argument 

在網站上經過一番研究,我嘗試了一些不同的東西,如改變HTTP到HTTPS或試圖讀取,但似乎沒有任何工作之前下載的文件。在閱讀文件之前嘗試下載文件時出現類似的錯誤。

+0

嗯......也許在你身邊。在R 3.3中,我可以讀取文件。嘗試在另一臺電腦上。 –

+0

而'read.xls'是來自哪個包? – Axeman

+0

read.xls來自軟件包gdata。這個想法來自這裏https://stackoverflow.com/questions/21738463/importing-excel-file-using-url-using-read-xls 任何人都知道另一種導入此文件的方法?沒有偏好的方法.. –

回答

0

Axeman指出我正確的方向。謝謝