首页 文章

从Linux服务器读取存储在SharePoint上的Excel文件(运行R Studio)

提问于
浏览
0

我正在尝试读取存储在企业Intranet SharePoint站点上的Excel文件,并且使用来自使用Shiny Server在Linux服务器上运行的R Studio中的“gdata”包 .

我在使用gdata的MS Windows环境中读取文件时获得了很好的结果,但是在Linux服务器上运行脚本时似乎无法正常工作 . 这是基于以下信息:

http://r.789695.n4.nabble.com/trying-to-import-xls-or-xlsx-files-td3620580.html

我确实修改了Linux服务器上Perl路径的R脚本(相对于Windows上perl.exe的路径),这似乎工作正常 .

文件网址是 "http://sharepoint2/ops/quality/metricspc/Metric OptIn List/temporary SPC Metric Opt-In List.xlsm"

这是R代码:

# R read MS Excel xlsm file from SharePoint
# method using gdata - seems to work with SharePoint 
# NOTE:  requires 'perl' installed
#
# example from
# http://r.789695.n4.nabble.com/trying-to-import-xls-or-xlsx-files-td3620580.html

library(gdata) 

fileurl =   
# see fileurl above this code section - did this due to SO error message about not having 'sharepoint2' in the url

d.optin.init2 <- read.xls(fileurl, 
                          sheet = "OPT-IN LIST", 
                          perl = "/usr/bin/perl")


##### END CODE #####

原始(基于Windows)脚本使用 perl = "C:\\Perl64\\bin\\perl.exe"

以下是产生的错误消息(在Shiny Server上使用R Studio从Linux运行时):

d.optin.init2 < - read.xls(fileurl,sheet =“OPT-IN LIST”,perl =“/ usr / bin / perl”)尝试URL'http:// sharepoint2 / ops / quality / metricspc / Metric选项列表/临时SPC指标选择列表.xlsm'download.file中的错误(xls,tf,mode =“wb”):无法打开URL'http:// sharepoint2 / ops / quality / metricspc / Metric OptIn List /临时SPC Metric Opt-In List.xlsm'另外:警告消息:在download.file(xls,tf,mode =“wb”)中:无法打开:HTTP状态为'400 Bad Request'错误在file.exists中(tfn ):无效的'file'参数

文件的路径(在SharePoint上)是一个URL(显示在代码中),所以我认为Linux服务器和MS SharePoint之间的路由可能很简单 . 但是因为这对我来说对Windows有用,但对我来说还不适用于Linux,我想知道我可能错过了什么?

提前感谢您提供的任何见解 .

(我没有附上Excel文件,因为我不确定这会对这个问题有所帮助 . )

最好的祝福,

悬崖

sessionInfo的输出

sessionInfo()R版本3.1.0(2014-04-10)平台:x86_64-redhat-linux-gnu(64位)语言环境:1 C附加基础包:1 stats graphics grDevices utils数据集方法基于其他附加包: 1 gdata_2.13.3 qcc_2.5通过命名空间加载(并未附加):1 MASS_7.3-31 gtools_3.4.1 tools_3.1.0

根据hrbrmstr和Greg提供的建议,我从Linux命令行尝试了wget和curl .

wget结果
wget results

卷曲结果
curl results

我可以与我们的IT人员一起解决 . 如果有人能帮助我根据这些结果改进我可能会问他们的问题,我会欢迎这一输入 .

再次感谢那些花时间回应的人 .

MORE FOLLOW-UP

@Gregory R. Warnes我能够在Linux服务器上使用wget和这个命令行:

wget --http-user = myusername --http-passwd = mypassword(在这里放置文件)

这似乎访问了该文件,弥合了Linux服务器和Windows SharePoint之间的鸿沟 .

现在来弄清楚如何在gdata R脚本中包含此AD身份验证 .

1 回答

  • 0

    该错误消息表明R的download.file()代码无法访问该URL .

    要调试此问题,请尝试从shell命令行从Linux服务器访问该URL,例如:

    如果安装了wget:

    > wget http://sharepoint2/ops/quality/metricspc/Metric OptIn List/temporary SPC Metric Opt-In List.xlsm
    

    或者如果安装了curl:

    > curl http://sharepoint2/ops/quality/metricspc/Metric OptIn List/temporary SPC Metric Opt-In List.xlsm
    

    如果wget和/或curl生成错误,那么您将遇到服务器配置问题 .

    如果wget和/或curl成功,那么问题可能在于R的download.file() .

    -Greg

相关问题