Using R to connect to a sharepoint list

前端 未结 3 457
旧时难觅i
旧时难觅i 2020-12-15 23:08

Has anyone been able to import a SharePoint list in R as a dataframe?

I have two separate data sources, one from a SharePoint list and the other from a DB that I wis

3条回答
  •  眼角桃花
    2020-12-15 23:25

    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 those aren't true: the following might work. At least it does for me on SharePoint 2010. If there's a better way of doing it when ListData.svc isn't present, I'd love to hear it.

     library(RCurl)
     library(XML)
     library(data.table)
     URL <- "http:///_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)
    

提交回复
热议问题