@@ -14,6 +14,56 @@ links_template <- paste(readLines("./data/input/links_template.txt"), collapse =
1414```
1515
1616``` {r read GRIIS checklist}
17- griis_checklist <- read_tsv("./data/output/UAT_processing/data_input_checklist_indicators.tsv")
17+ griis_checklist_raw <- read_tsv("./data/output/UAT_processing/data_input_checklist_indicators.tsv")
18+ ```
19+
20+ ``` {r prep griis checklist}
21+ griis_checklist <- griis_checklist_raw %>%
22+ filter(!is.na(nubKey)) %>%
23+ select(nubKey, scientificName = canonicalName, vernacular_name_nl, vernacular_name_en, vernacular_name_fr) %>%
24+ distinct() %>%
25+ separate(vernacular_name_nl, sep = ", ", into = "vernacular_name_nl", extra = "drop") %>%
26+ separate(vernacular_name_en, sep = ", ", into = "vernacular_name_en", extra = "drop") %>%
27+ separate(vernacular_name_fr, sep = ", ", into = "vernacular_name_fr", extra = "drop") %>%
28+ mutate(vernacular_name_nl = str_replace_na(vernacular_name_nl, ""),
29+ vernacular_name_en = str_replace_na(vernacular_name_en, ""),
30+ vernacular_name_fr = str_replace_na(vernacular_name_fr, ""))
31+ ```
32+
33+ ``` {r create link files}
34+ for(i in 1:nrow(griis_checklist)){
35+
36+ # get the current row
37+ current_row <- griis_checklist[i, ]
38+
39+ # create filename
40+ filename <- paste0("./HTML_pages/Rmd_files/", current_row$nubKey, ".Rmd")
41+
42+ # check if the file for the current row already exists
43+ if(file.exists(filename)){
44+ next
45+ }
46+
47+ # replace the placeholders in the template with actual values
48+ new_link <- links_template %>%
49+ gsub(pattern = "<--TAXONKEY-->",
50+ replacement = as.character(current_row$nubKey),
51+ x = .) %>%
52+ gsub(pattern = "<--SCIENTIFICNAME-->",
53+ replacement = current_row$scientificName,
54+ x = .) %>%
55+ gsub(pattern = "<--VERNACULAR_NAME_NL-->",
56+ replacement = current_row$vernacular_name_nl,
57+ x = .) %>%
58+ gsub(pattern = "<--VERNACULAR_NAME_EN-->",
59+ replacement = current_row$vernacular_name_en,
60+ x = .) %>%
61+ gsub(pattern = "<--VERNACULAR_NAME_FR-->",
62+ replacement = current_row$vernacular_name_fr,
63+ x = .)
64+
65+ # write the new link to a file
66+ writeLines(new_link, filename)
67+ }
1868```
1969
0 commit comments