#' Read a Power BI layout file into R as a list.
#
#' @param file Power BI layout file
#' @return list
#' @keywords read, layout
#' @export
#' @examples
#' \dontrun{
#' read_layout("Layout)
#' }
read_layout <- function(file){
file1 <- readLines(file, warn = FALSE, skipNul = TRUE)
file1 <- iconv(file1, "windows-1252", "UTF-8")
RJSONIO::fromJSON(file1, digits = 15)
}
#' Read a Power BI file into R as a list.
#
#' @param file Power BI file
#' @return list
#' @keywords read, layout
#' @export
#' @examples
#' \dontrun{
#' read_layout("example.pbix")
#' }
read_pbi <- function(file){
temp_dir <- tempdir()
unzip_folder_name <- stringi::stri_rand_strings(1, 20)
unzip_folder_path <- file.path(temp_dir, unzip_folder_name)
zip::unzip(file, exdir = unzip_folder_path)
read_layout(file.path(unzip_folder_path, "report/Layout"))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.