-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparse.js
More file actions
26 lines (21 loc) · 719 Bytes
/
Copy pathparse.js
File metadata and controls
26 lines (21 loc) · 719 Bytes
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
const fs = require("fs");
const files = [
"2021-10.json", "2021-11.json", "2021-12.json",
"2022-01.json", "2022-02.json", "2022-03.json", "2022-04.json", "2022-05.json", "2022-06.json",
"2022-07.json",'2022-11.json', '2022-12.json', '2023-01.json'
]
/**
*x
* @type {[date:string]: {[hours:string]: float}}
*/
const prices = {};
files.forEach(file => {
const content = fs.readFileSync(file)
const data = JSON.parse(content)
data[0].months[0].days.forEach(d => {
d.hours.forEach(h => {
prices[h.utcDateTime] = (Math.round(h.energyCostConsumptionPriceAvg * 100) / 100)
})
})
})
fs.writeFileSync("pages/dashboard/prices.json", JSON.stringify(prices,null, 2))