reduced_data = Object.values(raw.reduce((acumulator, current) => {
let key = `${current.country}-${current.year}`
const country = countries_loc.find(element => element.Country == current.country)
if(country != undefined){
sectors.map(sector => {
const new_key = key + `-${sector}`
acumulator[new_key] = {
country: current.country,
year: current.year,
sector: sector,
co2: current[`${sector == "luc"? "land_use_change" : sector == "other"? "other_industry" : sector}_co2`],
cumulative_co2: current[`cumulative_${sector}_co2`],
share_global_co2: current[`share_global_${sector}_co2`],
share_global_cumulative_co2: current[`share_global_cumulative_${sector}_co2`],
longitude: country.Longitude,
latitude: country.Latitude
}
})
}
return acumulator
}, {}))