From c5d398bd3fee5d175e1d0ac4bfdfbbdd62437139 Mon Sep 17 00:00:00 2001 From: msperlin Date: Thu, 16 May 2024 15:30:57 -0300 Subject: [PATCH] added conferences to output --- R/get_conferences.R | 28 ++++++++++++++++++++++++++++ R/gld_read_lattes_zip2.R | 10 +++++++++- vignettes/gld_vignette-ReadLattes.R | 2 +- 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 R/get_conferences.R diff --git a/R/get_conferences.R b/R/get_conferences.R new file mode 100644 index 0000000..cc86d99 --- /dev/null +++ b/R/get_conferences.R @@ -0,0 +1,28 @@ +get_conferences <- function(my_xml) { + + all_conf <- xml2::xml_find_all(my_xml, ".//APRESENTACAO-DE-TRABALHO") + + if (length(all_conf) != 0) { + + df_conf <- tibble::tibble() + + for (i_node in all_conf) { + conf_dados_basicos <- fetch_df(i_node, ".//DADOS-BASICOS-DA-APRESENTACAO-DE-TRABALHO") + + conf_detalhes <- fetch_df(i_node, ".//DETALHAMENTO-DA-APRESENTACAO-DE-TRABALHO") + + df_conf <- dplyr::bind_rows( + df_conf, + dplyr::bind_cols( + conf_dados_basicos, + conf_detalhes + ) + ) + } + + } else { + df_conf <- tibble::tibble() + } + + return(df_conf) +} diff --git a/R/gld_read_lattes_zip2.R b/R/gld_read_lattes_zip2.R index 59cabff..129cd85 100644 --- a/R/gld_read_lattes_zip2.R +++ b/R/gld_read_lattes_zip2.R @@ -62,6 +62,13 @@ gld_read_zip2 <- function(f_zip){ "got {nrow(accepted_papers)} accepted papers" ) + # conference papers + conferences <- get_conferences(my_xml) + + cli::cli_alert_success( + "got {nrow(conferences)} conferences" + ) + # books ---- books <- get_books(my_xml) @@ -111,7 +118,8 @@ gld_read_zip2 <- function(f_zip){ supervisions = superv_all, at_prof = at_prof, projects = projs, - coauthors = coauthors + coauthors = coauthors, + conferences = conferences ) # parse and fix list output diff --git a/vignettes/gld_vignette-ReadLattes.R b/vignettes/gld_vignette-ReadLattes.R index 929cfb6..ce654ff 100644 --- a/vignettes/gld_vignette-ReadLattes.R +++ b/vignettes/gld_vignette-ReadLattes.R @@ -19,7 +19,7 @@ f <- "~/Desktop/6915544029415506.zip" l_out <- gld_read_zip2(f) ## ----------------------------------------------------------------------------- -dplyr::glimpse(l_out) +dplyr::glimpse(l_out$conferences) ## ----------------------------------------------------------------------------- tpesq <- l.out$tpesq