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
The answer above works for lists which are <= 1000 rows only. Using "$Top" and "$Skip" in the URL, you can use the function below which iterates multiple times and imports all the data from the list regardless of the size. (This may not be the most clean way to write it, but it works!)
sp_import <- function(ListName) {
urlstring <- "http://yoursharepointserver/_vti_bin/ListData.svc/yourlist"
data <- xmlParse(readLines(paste(urlstring, ListName, sep = ""), warn = FALSE))
items <- getNodeSet(data, "//m:properties")
df <- xmlToDataFrame(items, stringsAsFactors = FALSE)
iterate <- nrow(df)
skip <- 1
while (nrow(df) == 1000 * skip) {
data <- xmlParse(readLines(paste(urlstring, ListName, "?$top=1000&$skip=", iterate, sep = ""), warn = FALSE))
items <- getNodeSet(data, "//m:properties")
df <- rbind(df, xmlToDataFrame(items, stringsAsFactors = FALSE))
iterate <- nrow(df)
skip <- skip + 1
}
return(df)
}