Skip to content

Instantly share code, notes, and snippets.

@AshKyd
Created November 29, 2023 00:32
Show Gist options
  • Save AshKyd/5553fade40d67ebc949e9c6ee103404f to your computer and use it in GitHub Desktop.
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.
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