25 lines
697 B
JavaScript
25 lines
697 B
JavaScript
import fs from "fs"
|
|
|
|
const data = JSON.parse(fs.readFileSync("data.json", "utf8"))
|
|
|
|
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")
|