From 248ac6620a0766857c46791a44e753ee14874344 Mon Sep 17 00:00:00 2001 From: Fionn Date: Sat, 11 Mar 2023 15:05:05 +0100 Subject: [PATCH] add utility script for converting csv points to json --- utils/convert-csv-to-json.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 utils/convert-csv-to-json.js diff --git a/utils/convert-csv-to-json.js b/utils/convert-csv-to-json.js new file mode 100644 index 0000000..a4f58ab --- /dev/null +++ b/utils/convert-csv-to-json.js @@ -0,0 +1,20 @@ +/** + * This script can be used to convert a csv-file to the json format required by the wx-config.json + * + * the csv needs to follow the following format: ,, + */ + +const fs = require('fs'); + +const points = fs + .readFileSync('./fixes.csv') + .toString() + .split('\n') + .map(str => str.split(',')) + .map(data => ({ + name: data[0], + lat: Number(data[1]), + lon: Number(data[2]), + })); + +fs.writeFileSync('./fixes.json', JSON.stringify(points, undefined, 2));