使用read.xls使用URL导入Excel文件 [英] Importing Excel file using url using read.xls

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

问题描述

我正在尝试使用gdata中的read.xls将Excel文件直接导入R.我正在运行64位R的Windows计算机上.

I'm trying to use read.xls from gdata to import an Excel file directly into R. I'm on a Windows machine running 64 bit R.

我已经检查了perl的PATH变量,并且似乎已正确设置了该变量,因此这似乎不是问题.这是我的代码,我在下面附加了我的错误.有人对我如何完成这项工作有任何指示吗?

I have checked my PATH variable for perl and I appear to have that set correctly, so that doesn't appear to be a problem. Here's my code, and I've attached my error below. Does anyone have any pointers on how I can get this done?

require(RCurl)
require(gdata)
url <- "https://dl.dropboxusercontent.com/u/27644144/NADAC%2020140101.xls"
test <- read.xls(url)

我得到的错误是:

Error in xls2sep(xls, sheet, verbose = verbose, ..., method = method,  : 
Intermediate file 'C:\Users\Me\AppData\Local\Temp\RtmpeoJNxP\file338c26156d7.csv' missing!
In addition: Warning message:
running command '"C:\STRAWB~1\perl\bin\perl.exe" "C:/Users/Me/Documents/R/win-library/3.0/gdata/perl/xls2csv.pl"  "https://dl.dropboxusercontent.com/u/27644144/NADAC%2020140101.xls" "C:\Users\Me\AppData\Local\Temp\RtmpeoJNxP\file338c26156d7.csv" "1"' had status 22 
Error in file.exists(tfn) : invalid 'file' argument

推荐答案

@ G.G是正确的,因为read.xls不支持https.但是,如果仅将url中的https替换为http,则应该可以下载文件.

@G.G is correct that read.xls does not support https. However, if you simply replace the https with http in the url you should be able to download the file.

尝试一下:

require(RCurl)
require(gdata)
url <- "http://dl.dropboxusercontent.com/u/27644144/NADAC%2020140101.xls"
test <- read.xls(url)

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

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