Data basic reading file

# A tibble: 1 × 6
  `Marca temporal`    `E-mail`  Fecha que se le asig…¹ Nombre Teléfono Dirección
  <dttm>              <chr>     <dttm>                 <chr>     <dbl> <chr>    
1 2022-04-18 13:49:39 dalg.95@… 2022-04-19 00:00:00    David… 42198581 11 calle…
# ℹ abbreviated name: ¹​`Fecha que se le asignó su consulta`

Testing multiple reading and consolidating

get list fichas

library(writexl)
library(readxl)
library(tidyverse)


list_excel_fichas <- list.files(path= "HospVetTest", full.names=TRUE)

Read excel Ficha and add filep_path variable

read_excel_ficha <- function(file) {
  if(is.na(file)) stop("no file path") # test if file exists 
  df <- readxl::read_excel(file, range = "A2:G3")
  df
}

Test on 1st ficha

read_excel_ficha(list_excel_fichas[1])
# A tibble: 1 × 7
  `Nombre del paciente` Especie Edad   Raza   Género Color `Estado reproductivo`
  <chr>                 <chr>   <chr>  <chr>  <chr>  <chr> <chr>                
1 Capi                  Canino  6 años Shitzu Macho  Blan… Esterilizada/castrado

Loop to read all excel fichas

df_list<- purrr::map(.x= list_excel_fichas, .f= read_excel_ficha)

get 1st data frame

df_1 <- df_list[[1]]

Loop to read and bind/merge all data frames by row

df_merged <- purrr::map_dfr(.x= list_excel_fichas, read_excel_ficha)
kable(df_merged)
Nombre del paciente Especie Edad Raza Género Color Estado reproductivo
Capi Canino 6 años Shitzu Macho Blanco y Café Esterilizada/castrado
Negro Canino 2 años aproximadamente SRD Macho Negro Intacto
Pepa Canino 4 años SRD Hembra Café Intacto
df_merged$edad.num <-as.numeric(gsub("[^0-9.-]", "", df_merged$Edad)) 
kable(df_merged)
Nombre del paciente Especie Edad Raza Género Color Estado reproductivo edad.num
Capi Canino 6 años Shitzu Macho Blanco y Café Esterilizada/castrado 6
Negro Canino 2 años aproximadamente SRD Macho Negro Intacto 2
Pepa Canino 4 años SRD Hembra Café Intacto 4

write excel (or GGsheet) with merged info

write_excel_csv(x= df_merged, file="MergedFichas")

### Using GgSheets