Using R to Connect to a Sharepoint List

Has anyone been able to import a SharePoint list into R as a data frame?

I have two separate data sources: one from the SharePoint list, and the other from the database on which I want to perform the analysis. I can connect to the database without any problems, but I can not find anything to connect to the SharePoint list.

SharePoint Server 2007

+6
source share
2 answers

I have been working on reading SharePoint 2010 lists using R for some time. Basically, I use a SharePoint web service to return results from a list, and then use xmlToDataFrame to convert to a data framework.

URL <- "http://yoursharepointserver/_vti_bin/ListData.svc/yourlist" data = xmlParse(readLines(URL)) ## get the individual list items items = getNodeSet(data, "//m:properties") ## convert to a data frame df = xmlToDataFrame(items, stringsAsFactors = FALSE) 

Since I use a web service, I can filter the list before returning the results, which is very useful for overcoming the limitations of the SharePoint web service. The following link is very useful ... http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2010/01/21/introduction-to-querying-lists-with-rest-and-listdata-svc-in-sharepoint -2010.aspx

+8
source

Lee Mendoza's answer may well work if ListData.svc is running and / or you have administrative access to the SharePoint server.

If both of them are incorrect: the following may work. At least this is for me in SharePoint 2010. If there is a better way to do this when ListData.svc is missing, I would like to hear it.

  library(RCurl) library(XML) library(data.table) URL <- "http://<site>/_vti_bin/owssvr.dll?Cmd=Display&Query=*&XMLDATA=TRUE&List={GUID_OF_LIST}" rawData <- getURL(URL, userpwd = "username:password") # in real life prompt for user credentials, don't put in script xmlData <- xmlParse (rawData, options=HUGE, useInternalNodes=TRUE) dataList <- xmlToList(xmlRoot(xmlData)[["data"]]) # check the system return, on my SP2010 server the data block is # named rs:data so this works dataMatrix <- do.call(rbind,dataList) finalDataTable <- data.table(dataMatrix) 
+2
source

Source: https://habr.com/ru/post/983176/


All Articles