24 lines
672 B
JavaScript
24 lines
672 B
JavaScript
const data = require("./data.json")
|
|
const fs = require("fs")
|
|
|
|
const dataPerRegion = {}
|
|
|
|
for (const item of data) {
|
|
if (!dataPerRegion[item.regionName]) {
|
|
dataPerRegion[item.regionName] = []
|
|
}
|
|
const connectedSystems = item.connectedSystems.split(",")
|
|
item.connectedSystems = connectedSystems
|
|
dataPerRegion[item.regionName].push(item)
|
|
delete item.regionName
|
|
}
|
|
|
|
for (const region in dataPerRegion) {
|
|
const sanitizedRegion = region.replaceAll(" ", "_").replaceAll("-", "_")
|
|
const regionFile = `public/${sanitizedRegion}.json`
|
|
console.log("Writing to", regionFile)
|
|
fs.writeFileSync(regionFile, JSON.stringify(dataPerRegion[region], null, 2))
|
|
}
|
|
|
|
console.log("Done")
|