library(xml2)
library(dplyr)
# Download and unpack ALL_CONCEPTSCHEMES.xml from:
# https://ec.europa.eu/eurostat/api/dissemination/sdmx/2.1/conceptscheme/ESTAT/?compressed=true
xml_object <- xml2::read_xml("ALL_CONCEPTSCHEMES.xml")
concepts <- xml2::xml_find_all(xml_object, ".//s:Concept")
number <- length(concepts)
dic_df <- data.frame(
code_name = xml2::xml_attr(concepts, "id"),
full_name = xml2::xml_text(xml2::xml_find_all(concepts, "./c:Name[@xml:lang='en']"))
)
# Clean and format to match old .dic style
new_df_sort <- dic_df %>%
distinct() %>%
mutate(code_name = toupper(code_name)) %>%
arrange(code_name)
rownames(new_df_sort) <- NULL