diff --git a/loadDB.R b/loadDB.R index 48090c6403d177cf398ea4a3a083687b7129aa90..1b6d2a4361f39cb688e1cbdfe88b61acc7ae495b 100644 --- a/loadDB.R +++ b/loadDB.R @@ -15,13 +15,21 @@ library(tidyr) library(dplyr) +### Load management regimes +# --------------------------- + +# Management regimes and their abbreviation, they are merged to the data by the branching group (script loadDB.R) +regime <- read.csv(paste0(path, "/params/regimes.csv"), + sep = ",", + stringsAsFactors = FALSE) + # Variant 1: create a single dataframe for each SQL Database (selected columns of table UNIT) # Dataframes are given the names of the DB and column "test" is added with the name of the DB for (name in db_names){ - #name = "simulated_without_MV_Korsnas_Wind_NO_1-15" + # name = "simulated_without_MV_Korsnas_Wind_three_286-300" #db <- dbConnect(dbDriver("SQLite"), dbname = paste0(path,"input_data/simulated_", sim_variant, "_", name, "_rsu.db")) db <- dbConnect(dbDriver("SQLite"), dbname = paste(inputFolder, @@ -47,16 +55,23 @@ for (name in db_names){ ### Rename set aside scenario if it considers deadwood extraction - if(sim_variant %in% all.variants) { + # Maybe now we can remove this???? + #if(sim_variant %in% all.variants) { - rsl <- rsl %>% mutate(regime = ifelse(regime %in% "SA", "SA_DWextract", regime)) + #rsl <- rsl %>% mutate(regime = ifelse(regime %in% "SA", "SA_DWextract", regime)) - } + #} + + # Create output name, Remove the 'simulated_' + outName <- gsub("simulated_", "", name) + # Export the final table - print(paste0("writing csv for ", name)) + print(paste0("writing csv for ", outName)) + + write.table(rsl, - paste0(outputFolder, "/", name, ".csv" ), + paste0(outputFolder, "/", outName, ".csv" ), sep = ";", row.names = F, col.names = TRUE)