-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathcreateElectricityJSON.js
60 lines (56 loc) · 1.58 KB
/
createElectricityJSON.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// create electricity JSON using electricity emissions provided.
// Use command `node createElectricityJSON.js | cat > electricity.json`
// to get a JSON file
const data = require('./electricity_emission.json');
console.log(`[
{
"item": "electricity",
"region": "Default",
"quantity": 1,
"units": "kWh",
"categories": ["electricity"],
"components": [
{ "name": "generation", "quantity": 1, "units": "kWh" },
{ "name": "td", "quantity": 1, "units": "kWh" }
]
},`);
for (let i = 0; i < data.length; i++) {
const obj = ` {
"item": "generation",
"region": "${data[i].Country}",
"quantity": 1,
"units": "kWh",
"categories": ["electricity"],
"components": [
{ "name": "CO2", "quantity": ${
data[i]['Generation-CO2']
}, "units": "kg CO2/kWh" },
{ "name": "CH4", "quantity": ${
data[i]['Generation-CH4']
}, "units": "kg CH4/kWh" },
{ "name": "N2O", "quantity": ${
data[i]['Generation-N2O']
}, "units": "kg N2O/kWh" }
]
},
{
"item": "td",
"region": "${data[i].Country}",
"quantity": 1,
"units": "kWh",
"categories": ["electricity"],
"components": [
{ "name": "CO2", "quantity": ${
data[i]['Td-CO2']
}, "units": "kg CO2/kWh" },
{ "name": "CH4", "quantity": ${
data[i]['Td-CH4']
}, "units": "kg CH4/kWh" },
{ "name": "N2O", "quantity": ${
data[i]['Td-N2O']
}, "units": "kg N2O/kWh" }
]
},`;
console.log(obj);
}
console.log(']');