-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: get urls from tableau workbook
- Loading branch information
Showing
4 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#' Get Workbook URLs | ||
#' | ||
#' This function parses an XML document representing a Tableau workbook and finds all nodes that have a url attribute containing 'views'. | ||
#' It then extracts these URLs and returns them in a data frame. | ||
#' | ||
#' @param wb The path to the Tableau workbook file (.twb). | ||
#' | ||
#' @return A data frame containing the URLs found in the workbook. | ||
#' @export | ||
get_workbook_urls <- function(wb) { | ||
# Parse the XML document | ||
doc <- XML::xmlParse(wb) | ||
|
||
# Get the root node | ||
root <- XML::xmlRoot(doc) | ||
|
||
# Find all nodes that have a url attribute containing 'views' | ||
nodes <- XML::xpathSApply(root, "//*[contains(@url, 'views')]") | ||
|
||
# Initialize an empty vector to store the URLs | ||
urls <- character(length(nodes)) | ||
|
||
# Loop over the nodes | ||
for (i in seq_along(nodes)) { | ||
# Extract the URL attribute | ||
url <- XML::xmlGetAttr(nodes[[i]], "url") | ||
|
||
# Store the URL in the urls vector | ||
urls[i] <- url | ||
} | ||
|
||
# Convert the urls vector to a data frame | ||
dfUrls <- data.frame(URL = urls) | ||
|
||
return(dfUrls) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -206,5 +206,6 @@ reference: | |
- get_variables | ||
- get_workbook_id | ||
- get_workbook_tabs | ||
- get_workbook_urls | ||
- make_rootnodes | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.