Skip to content

Commit c57034c

Browse files
committed
export senierungen too
1 parent e30d975 commit c57034c

File tree

2 files changed

+52
-3
lines changed

2 files changed

+52
-3
lines changed

pages/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ const MapSite: NextPage = (energyData: any) => {
185185
const { action, index, status, type } = jRData
186186

187187
console.log(action, index, status, type)
188+
console.log(EVENTS.STEP_AFTER)
188189

189190
if ([EVENTS.STEP_AFTER, EVENTS.TARGET_NOT_FOUND].includes(type)) {
190191
let tempIndex

src/lib/toCSV.js

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ export function toCSV(pointData) {
33
x: 'lat',
44
y: 'lng',
55
houseComment: 'kommentar',
6+
entityAddress: 'adresse',
7+
entityPLZ: 'plz',
8+
entityType: 'type',
9+
houseArea: 'fleach',
10+
houseCosts: 'kosten',
11+
houseMonument: 'denkmal',
12+
houseName: 'name',
13+
housePrio: 'prio',
14+
houseSavingPotential: 'einsparpotenzial',
615
}
716
const verbrauchWant = [
817
'entityId',
@@ -21,37 +30,76 @@ export function toCSV(pointData) {
2130
'renovationsSavingsMax',
2231
'renovationsSavingsMin',
2332
]
33+
const sanierungWant = [
34+
'entityAddress',
35+
// 'entityId',
36+
'entityPLZ',
37+
'entityType',
38+
'houseArea',
39+
'houseCosts',
40+
'houseMonument',
41+
'houseName',
42+
'housePrio',
43+
'houseSavingPotential',
44+
]
45+
2446
let headersVerbrauch = ''
2547
verbrauchWant.forEach((head, i) => {
2648
headersVerbrauch += headerTranslation[head] ? headerTranslation[head] : head
2749
headersVerbrauch += verbrauchWant.length - 1 == i ? '' : ','
2850
})
2951
headersVerbrauch += '\n'
3052

53+
let headersSanierungen = ''
54+
sanierungWant.forEach((head, i) => {
55+
headersSanierungen += headerTranslation[head]
56+
? headerTranslation[head]
57+
: head
58+
headersSanierungen += sanierungWant.length - 1 == i ? '' : ','
59+
})
60+
headersSanierungen += '\n'
61+
3162
let rowsVerbrauch = ''
3263
pointData.features.forEach((feat) => {
64+
console.log(feat.properties.renovations)
3365
verbrauchWant.forEach((d, ii) => {
3466
rowsVerbrauch += Number(feat.properties[d])
3567
? feat.properties[d]
3668
: '"' + feat.properties[d] + '"'
3769
const comma = verbrauchWant.length - 1 == ii ? '' : ','
3870
rowsVerbrauch += comma
3971
})
40-
4172
rowsVerbrauch += '\n'
4273
})
4374

75+
let rowsSanierung = ''
76+
pointData.features.forEach((feat) => {
77+
feat.properties.renovations.forEach((renovation, ii) => {
78+
sanierungWant.forEach((d, ii) => {
79+
rowsSanierung += Number(renovation[d])
80+
? renovation[d]
81+
: '"' + renovation[d] + '"'
82+
const comma = sanierungWant.length - 1 == ii ? '' : ','
83+
rowsSanierung += comma
84+
})
85+
rowsSanierung += '\n'
86+
})
87+
})
88+
4489
let csvVerbrauch =
4590
'data:text/csv;charset=utf-8,' + headersVerbrauch + rowsVerbrauch
4691

92+
let csvSanierung =
93+
'data:text/csv;charset=utf-8,' + headersSanierungen + rowsSanierung
94+
4795
var encodedUri = encodeURI(csvVerbrauch)
4896
var link = document.createElement('a')
4997
link.setAttribute('href', encodedUri)
50-
link.setAttribute('download', 'odis-verbrauche.csv')
98+
link.setAttribute('download', 'odis-verbrauch.csv')
5199
document.body.appendChild(link) // Required for FF
52100
link.click() // This will download the data file named "my_data.csv".
53101

54-
var encodedUri = encodeURI(csvVerbrauch)
102+
var encodedUri = encodeURI(csvSanierung)
55103
var link2 = document.createElement('a')
56104
link2.setAttribute('href', encodedUri)
57105
link2.setAttribute('download', 'odis-sanierungen.csv')

0 commit comments

Comments
 (0)