table_data_to_plot = {
let list_of_countries = Object.keys(countries_to_id_dict);
return list_of_countries.map(function(country_key) {
let row = {};
let three_letter_country_key = "";
if (country_key in countries_dict_iso2) {
three_letter_country_key = countries_dict_iso2[country_key].id;
} else {
debugger;
}
row["iso2code"] = country_key;
row["country_name"] = countries_to_id_dict[country_key]["name"];
row["country_id"] = countries_to_id_dict[country_key]["id"];
row["primary_energy_per_capita_kg_oil_eq"] = get_value_if_exists(
pepc_dict,
three_letter_country_key
);
row["total_final_energy_consumption_tj"] = get_value_if_exists(
tfec_dict,
three_letter_country_key
);
row["population"] = get_value_if_exists(
population_dict,
three_letter_country_key
);
let pepcoe = row["primary_energy_per_capita_kg_oil_eq"];
row["primary_energy_per_capita_kwh"] = convert_kg_oil_eq_to_kwh(pepcoe);
let pop = row["population"];
let tfec = row["total_final_energy_consumption_tj"];
row[
"final_energy_consumption_per_capita_kwh"
] = convert_tfec_to_kwh_per_capita(tfec, pop);
return row;
});
}