Skip to content

Instantly share code, notes, and snippets.

@Tungurahua
Last active August 29, 2015 14:17
Show Gist options
  • Save Tungurahua/a1aa7044a3a46c8b8eec to your computer and use it in GitHub Desktop.
Save Tungurahua/a1aa7044a3a46c8b8eec to your computer and use it in GitHub Desktop.
Netgreen script
library(RJSDMX)
library(xlsx)
library(reshape2)
extractor <- function(dataflow){
namelist <- names(getDimensions("EUROSTAT",dataflow))
codelist <- lapply(namelist,function(x){getCodes("EUROSTAT",flow = dataflow,dimension = x )})
dims <- sapply(codelist,function(x){names(x[1])})
dims <- dims[1:(length(dims)-1)]
idstring <- paste0(c(dataflow,dims), collapse=".")
idstring <- paste0(idstring,".")
df <- getSDMX(provider = "EUROSTAT",id = idstring)
df.meta <- sdmxdf(df,meta = T)
df.meta <- df.meta[,!names(df.meta) %in% c("ID","STATUS")]
minimum <- min(as.numeric(as.character(df.meta$TIME)))
maximum <- max(as.numeric(as.character(df.meta$TIME)))
countries <- paste0(levels(df.meta$GEO), collapse = ", ")
dfout <- data.frame(Code=dataflow, Min=minimum, Max=maximum, Countries=countries)
return(dfout)
}
result <- lapply(c("tsdph100",
"ilc_lvho02",
#"teilm310",#Uncommenting this row will break the loop
"nrg_110a",
"tsdec240",
"tsdec210",
"earn_nt_net",
"for_vol",
"t2020_rl110",
"tsdsc260",
"spr_net_ben",
#"teicp040",
"tsdsc330",
"une_rt_a",
"educ_regind",
"nama_t20_21_k",
#"tsdde520",
#"t2020_rt200",
"nama_t20_21_k",
#"tsdgp220",
"tsdpc240",
"tsdec330",
#"t2020_10",
"tessi012",
"tsdpc100",
#"t2020_rn200",
#"tsdpc410",
"tsdpc220",
"tsdph270",
#"t2020_rn110",
"tsdpc220",
#"tsdnr310",
#"tsdpc420",
"tsdec320",
#"t2020_rt120",
"tsdpc280",
#"tsdec340",
#"t2020_rn300",
"tsdec430",
"hlth_silc_11",
"tsdec310",
#"t2020_10",
"ilc_mdes05",
"tps00071",
"ilc_di11",
#"tsdgp230",
"hlth_silc_01",
"ten00049",
"tsdpc280",
"ilc_lvps02"),function(x){extractor(x)})
final.result <- do.call("rbind",result)
write.xlsx(x = final.result, file = "test.excelfile.xlsx",
sheetName = "ESTAT_batch01", row.names = FALSE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment