Skip to content

Commit

Permalink
check for raw scenario data files before importing (#231)
Browse files Browse the repository at this point in the history
  • Loading branch information
cjyetman authored May 2, 2024
1 parent a5bb49a commit ffa4652
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions run_pacta_data_preparation.R
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,12 @@ relevant_years <-
)
logger::log_info("Full time horizon set to: {paste0(relevant_years, collapse = ', ')}.")

scenario_raw_data_to_include <-
lapply(
X = config[["scenario_raw_data_to_include"]],
FUN = function(x) {
readr::read_csv(
file = file.path(config[["scenarios_data_path"]], paste0(x, ".csv")),
show_col_types = FALSE
)
}
scenario_data_file_paths <-
file.path(
config[["scenarios_data_path"]],
paste0(config[["scenario_raw_data_to_include"]], ".csv")
)
names(scenario_data_file_paths) <- basename(scenario_data_file_paths)

factset_timestamp <-
unique(sub("_factset_.*[.]rds$", "", c(
Expand Down Expand Up @@ -180,7 +176,8 @@ input_filepaths <- c(
factset_iss_emissions_data_path = factset_iss_emissions_data_path,
factset_issue_code_bridge_path = factset_issue_code_bridge_path,
factset_industry_map_bridge_path = factset_industry_map_bridge_path,
factset_manual_pacta_sector_override_path = factset_manual_pacta_sector_override_path
factset_manual_pacta_sector_override_path = factset_manual_pacta_sector_override_path,
scenario_data_file_paths
)

if (!config[["update_currencies"]]) {
Expand All @@ -202,6 +199,18 @@ if (length(missing_input_files) > 0L) {

logger::log_info("Fetching pre-flight data.")

logger::log_info("Importing raw scenrio data.")
scenario_raw_data_to_include <-
lapply(
X = config[["scenario_raw_data_to_include"]],
FUN = function(x) {
readr::read_csv(
file = file.path(config[["scenarios_data_path"]], paste0(x, ".csv")),
show_col_types = FALSE
)
}
)

if (config[["update_currencies"]]) {
logger::log_info("Fetching currency data.")
input_filepaths <- c(
Expand Down

0 comments on commit ffa4652

Please sign in to comment.