R/get_columns_attributes_template_data.R

Defines functions get_columns_attributes_template_data

Documented in get_columns_attributes_template_data

#' @title Retrieve attributes
#' 
#' @description Goes through the template load data to retrieve all the attributes mentionned.
#' 
#' @author Briac LE RAY (briac.leray@partnre.com)
#' 
#' @return A dataframe containing the names of the tables and the names of the attributes.
#' @param template_load_data The filled template. Type = dataframe
#' @examples get_columns_attributes_template_data(template_load_data = my_filled_template)

get_columns_attributes_template_data <- function(template_load_data) {
  columns_attributes = data.frame(table_source = character(), attributes = character())
  
  for (row in 1:nrow(template_load_data)) {
    line = template_load_data[row,]
    
    for (attribute in str_split(string = line[["Nom_du_champ_source"]], pattern = ",")) {
      columns_attributes = bind_rows(columns_attributes,
                                     data.frame(table_source = line[["Nom_de_la_table_source"]], attributes = attribute))
    }
  }
  return(distinct(columns_attributes))
}
Tiipiac/StressTestOptimization documentation built on Dec. 18, 2021, 5:08 p.m.