-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
81 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
Package: aspe | ||
Type: Package | ||
Title: Import, Process and Visualise the French River Fish Database ASPE | ||
Version: 0.1.16 | ||
Version: 0.1.17 | ||
Author: Pascal Irz <[email protected]> | ||
Maintainer: Pascal Irz <[email protected]> | ||
Description: The aspe package provides a suite of tools for most of the common | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#' Obtenir les commentaires qui donnent la signification des champs des tables | ||
#' | ||
#' @param fichier_dump Le chemin vers le fichier d'extension .sql (décompressé) ou | ||
#' .sql.gz (archive). | ||
#' | ||
#' @return Un dataframe avec pour chacun des champs sa table d'appartenance et sa signification. | ||
#' @export | ||
#' | ||
#' @importFrom stringr str_replace str_subset str_sub str_extract | ||
#' | ||
#' @examples | ||
#' \dontrun{ | ||
#' expl_commentaires_champs(fichier_dump = "../raw_data/dump.sql") | ||
#' } | ||
#' | ||
#' | ||
expl_commentaires_champs <- function(fichier_dump) { | ||
|
||
lignes_dump <- imp_lire_lignes_dump(fichier_dump) | ||
|
||
# sélection des lignes contenant les commentaires des champs | ||
mes_lignes <- lignes_dump %>% | ||
stringr::str_subset(pattern = 'COMMENT ON COLUMN') %>% | ||
str_replace("COMMENT ON COLUMN ", "") | ||
|
||
# noms de la table = préfixe du nom complet du champ | ||
nom_table <- mes_lignes %>% | ||
str_extract("[^\\.]*") | ||
|
||
# nom du champ | ||
nom_var <- mes_lignes %>% | ||
str_replace("[^\\.]*", "") %>% | ||
str_replace("\\.", "") %>% | ||
str_extract("[^ IS ]*") | ||
|
||
# commentaire sur le champ | ||
comm_var <- mes_lignes %>% | ||
str_replace("[^ IS ]*", "") %>% | ||
str_replace(" IS ", "") %>% | ||
str_sub(start = 2, end = -3) %>% | ||
str_replace("''", "'") | ||
|
||
# assemblage du résultat ; suppression des champs des tables temporaires | ||
data.frame(nom_table, | ||
nom_var, | ||
comm_var) %>% | ||
filter(!str_detect(nom_table, "^temp_")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.