Skip to content

Commit

Permalink
Add 6 wood total stock columns
Browse files Browse the repository at this point in the history
  • Loading branch information
hfroot committed Oct 13, 2023
1 parent c3a3fc5 commit 20118ab
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion scripts/csv-generation-one-line.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,25 @@ const WOOD_USAGES = ['bo', 'bi']
WOOD_USAGES.forEach((usage) => {
STOCKS_HEADERS.push(...[
{ id: `${usage}_harvest`, title: `${usage}_recolte_locale_m3_an-1` },
{ id: `${usage}_harvestRatio`, title: `${usage}_ratio_recolte_France` }
{ id: `${usage}_harvestRatio`, title: `${usage}_ratio_recolte_France` },
{ id: `${usage}_harvestTotal`, title: `${usage}_recolte_total_tC` }
])
})

STOCKS_HEADERS.push(...[
{ id: 'wood_harvestTotal', title: 'produit_bois_recolte_total_tC' }
])

WOOD_USAGES.forEach((usage) => {
STOCKS_HEADERS.push(...[
{ id: `${usage}_populationTotal`, title: `${usage}_consommation_total_tC` }
])
})

STOCKS_HEADERS.push(...[
{ id: 'wood_populationTotal', title: 'produit_bois_consommation_total_tC' }
])

function createRecordForCommune (commune) {
const record = communeData[commune.insee]
// fill in geographical data not in extended commune data
Expand Down Expand Up @@ -192,7 +207,11 @@ function addStocksRecords (records, record) {
WOOD_USAGES.forEach((usage) => {
record[`${usage}_harvest`] = woodHarvestStock[`${usage}LocalHarvestTotal`]
record[`${usage}_harvestRatio`] = woodHarvestStock[`${usage}Portion`]
record[`${usage}_harvestTotal`] = woodHarvestStock[`${usage}Stock`]
record.wood_harvestTotal = woodHarvestStock.totalStock
record.populationRatio = woodConsumptionStock.portionPopulation
record[`${usage}_populationTotal`] = woodConsumptionStock[`${usage}Stock`]
record.wood_populationTotal = woodConsumptionStock.totalStock
})
record.stock = stocks.total
records.push(record)
Expand Down

0 comments on commit 20118ab

Please sign in to comment.