data = rawData
.map(({ YYYYMM, Value, Description }) => {
const year = +YYYYMM.slice(0, 4)
const month = +YYYYMM.slice(4, 6)
const sourceMatch = Description.match(
/Electricity Net Generation From (.*), All Sectors/
)
const value = +Value
return month !== 13 || !sourceMatch || isNaN(value)
? null
: {
date: new Date(year, 0),
value: value,
source: sourceMatch[1]
}
})
.filter(Boolean)