Created
November 29, 2023 00:32
-
-
Save AshKyd/5553fade40d67ebc949e9c6ee103404f to your computer and use it in GitHub Desktop.
Make a tsv file out of a geojson blob. The properties must all be consistent or this won't really work.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const geojson = require('file.geojson'); | |
function makeLine(object){ | |
return Object.keys(object).map(key => { | |
const value = object[key]; | |
if(!['string', 'number'].includes(typeof value)) return '-'; | |
return value; | |
}).join('\t') | |
} | |
require('fs').writeFileSync('tsv.tsv', [ | |
Object.keys(geojson.features[0].properties).join('\t'), | |
cables.features.map(feature => makeLine(feature.properties)).join('\n') | |
].join('\n')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment