-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #396 from Open-Earth-Foundation/mendoza_EIE_integr…
…ation Mendoza eie integration
- Loading branch information
Showing
24 changed files
with
4,031 additions
and
55 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
global-api/importer/argentinian_datasets/ENARGAS/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# ENARGAS | ||
Gas consumption data for argentinian provinces | ||
|
||
1. Extract the activity data from the source [ENARGAS](https://dod.enargas.gob.ar/) (manually): | ||
- variable: consumo de gas | ||
- aspectos: tipo de usuario | ||
- distribuidora: todos | ||
- desagregación espacial: provincia | ||
- desagregación temporal: anual | ||
- año: 2018 al 2022 (para tener años completos) | ||
|
||
**data accesed: March, 12th 2023** | ||
|
||
2. Transform activity data into emissions data aligned with the global API schema: | ||
```bash | ||
python ./importer/argentinian_datasets/ENARGAS/transformation_ENARGAS.py --filepath [path where the transformed data will be saved] | ||
``` | ||
|
||
3. Extract the activity row from the source: | ||
```bash | ||
psql -U ccglobal -d ccglobal -f ./importer/argentinian_datasets/ENARGAS/load_ENARGAS.sql | ||
``` |
34 changes: 34 additions & 0 deletions
34
global-api/importer/argentinian_datasets/ENARGAS/load_ENERGAS.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
-- Create a staging table | ||
CREATE TEMP TABLE IF NOT EXISTS ENARGAS_staging (LIKE regionwide_emissions INCLUDING ALL); | ||
|
||
-- Clear the staging table | ||
TRUNCATE ENARGAS_staging; | ||
|
||
-- Load the staging table from the downloaded file | ||
\copy ENARGAS_staging ("GPC_refno",activity_name,activity_units,activity_value,emission_factor_units,emission_factor_value,emissions_units,emissions_value,gas_name,id,region_name,region_code,source_name,temporal_granularity,year) FROM '/Users/maureenfonseca/Documents/OEF/Cities/CityCatalyst/global-api/importer/argentinian_datasets/ENARGAS/processed_enargas_gas_consumption_AR.csv' WITH (FORMAT CSV, HEADER); | ||
|
||
-- Update the main table with the staging table | ||
INSERT INTO regionwide_emissions ("GPC_refno",activity_name,activity_units,activity_value,emission_factor_units,emission_factor_value,emissions_units,emissions_value,gas_name,id,region_name,region_code,source_name,temporal_granularity,year) | ||
SELECT "GPC_refno",activity_name,activity_units,activity_value,emission_factor_units,emission_factor_value,emissions_units,emissions_value,gas_name,id,region_name,region_code,source_name,temporal_granularity,year | ||
FROM ENARGAS_staging | ||
ON CONFLICT ON CONSTRAINT regionwide_emissions_pkey | ||
DO UPDATE SET | ||
id = excluded.id, | ||
source_name = excluded.source_name, | ||
"GPC_refno" = excluded."GPC_refno", | ||
region_name = excluded.region_name, | ||
region_code = excluded.region_code, | ||
temporal_granularity = excluded.temporal_granularity, | ||
year = excluded.year, | ||
activity_name = excluded.activity_name, | ||
activity_value = excluded.activity_value, | ||
activity_units = excluded.activity_units, | ||
gas_name = excluded.gas_name, | ||
emission_factor_value = excluded.emission_factor_value, | ||
emission_factor_units = excluded.emission_factor_units, | ||
emissions_value = excluded.emissions_value, | ||
emissions_units = excluded.emissions_units; | ||
|
||
-- Drop the staging table | ||
DROP TABLE ENARGAS_staging; | ||
|
1,549 changes: 1,549 additions & 0 deletions
1,549
global-api/importer/argentinian_datasets/ENARGAS/processed_enargas_gas_consumption_AR.csv
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.