Reputation: 193
I am trying to read an Excel file that is stored on a corporate intranet SharePoint site, and am doing so using the 'gdata' package from within R Studio run on a Linux server using Shiny Server.
I had good results reading the file from within a MS Windows environment using gdata, but cannot seem to get things to work when running the script on the Linux server. This was based on the info from:
http://r.789695.n4.nabble.com/trying-to-import-xls-or-xlsx-files-td3620580.html
I did modify the R script for the path to Perl on the Linux server (vs. the path to perl.exe on Windows), and this seems to work ok.
The file url is
"http://sharepoint2/ops/quality/metricspc/Metric OptIn List/temporary SPC Metric Opt-In List.xlsm"
Here is the R code:
# 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 #####
The original (Windows-based) script used perl = "C:\\Perl64\\bin\\perl.exe"
Here is the error message that results (when run from Linux using R Studio on Shiny Server):
d.optin.init2 <- read.xls(fileurl, + sheet = "OPT-IN LIST", + perl = "/usr/bin/perl") trying URL
'http://sharepoint2/ops/quality/metricspc/Metric OptIn List/temporary SPC Metric Opt-In List.xlsm'
Error in download.file(xls, tf, mode = "wb") : cannot open URL
'http://sharepoint2/ops/quality/metricspc/Metric OptIn List/temporary SPC Metric Opt-In List.xlsm'
In addition: Warning message: In download.file(xls, tf, mode = "wb") : cannot open: HTTP status was '400 Bad Request'
Error in file.exists(tfn) : invalid 'file' argument
The path to the file (on SharePoint) is a URL (shown in the code), so I thought that the route between the Linux server and MS SharePoint might be straightforward. But since this does work for me with Windows but does not yet work for me with Linux, I wonder what I may have missed?
Thank you in advance for any insight that might be offered.
(I haven't attached the Excel file because I wasn't sure that it would help with this question.)
Best regards,
Cliff
Output from sessionInfo
sessionInfo() R version 3.1.0 (2014-04-10) Platform: x86_64-redhat-linux-gnu (64-bit)
locale: 1 C
attached base packages: 1 stats graphics grDevices utils datasets methods base
other attached packages: 1 gdata_2.13.3 qcc_2.5
loaded via a namespace (and not attached): 1 MASS_7.3-31 gtools_3.4.1 tools_3.1.0
Acting on the suggestions provided by hrbrmstr and also Greg, I tried both wget and also curl from the Linux command line.
wget results
curl results
I can work with our IT folks to resolve. If anyone can help me to refine the questions I might ask of them based on these results, I would welcome this input.
Thanks again to those who took the time to respond.
MORE FOLLOW-UP
@Gregory R. Warnes I was able to use wget with this command line from the Linux server:
wget --http-user=myusername --http-passwd=mypassword (place fileurl here)
This seemed to access the file, bridging the divide between Linux server and Windows SharePoint.
Now to figure out how to include this AD authentication in the gdata R script.
Upvotes: 0
Views: 5583
Reputation: 565
The error message indicates that R's download.file() code was not able to access the URL.
To debug the issue, try accessing that URL from the Linux server from the shell command line, for example:
If wget is installed:
> wget http://sharepoint2/ops/quality/metricspc/Metric OptIn List/temporary SPC Metric Opt-In List.xlsm
or if curl is installed:
> curl http://sharepoint2/ops/quality/metricspc/Metric OptIn List/temporary SPC Metric Opt-In List.xlsm
If wget and/or curl generates an error, then you have a server configuration issue.
If wget and/or curl succeed then the problem may be with R's download.file().
-Greg
Upvotes: 0