mirror of
https://github.com/dotFionn/iassure-wx.git
synced 2026-03-16 20:42:55 -05:00
add utility script for converting csv points to json
This commit is contained in:
20
utils/convert-csv-to-json.js
Normal file
20
utils/convert-csv-to-json.js
Normal file
@@ -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: <FIX>,<LAT>,<LON>
|
||||||
|
*/
|
||||||
|
|
||||||
|
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));
|
||||||
Reference in New Issue
Block a user