R/read_files_utils.R

Defines functions detect_sep co_unidade_ensino num_para_cpf

num_para_cpf <- function(cpf) {
  
  cpf <- stringr::str_pad(cpf, 11, pad = "0")
  stringr::str_replace(string = cpf,
                       pattern = "([0-9]{3})([0-9]{3})([0-9]{3})",
                       replacement = "\\1.\\2.\\3-")
}

co_unidade_ensino <- function(){
  utils::read.csv(system.file("extdata/co_unidade_ensino/co_unidade_ensino.csv", package = "sistec"),
                              colClasses = "character")
}


detect_sep <- function(x){
  header <- readLines(x, n = 1, encoding = "UTF-8")
  comma_sep <- stringr::str_detect(header, ",")
  if(comma_sep){
    sep = ","
  } else {
    sep = ";"
  }
  
  sep
}

Try the sistec package in your browser

Any scripts or data that you put into this service are public.

sistec documentation built on Oct. 27, 2020, 1:06 a.m.