cat line-delimitted-geo-data.json | node to-collection.js > valid-geojson.json
Created
March 6, 2018 22:27
-
-
Save morganherlocker/bc506c813c946788b587f60f4ac66eec to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var fs = require('fs'); | |
var byline = require('byline'); | |
var through2 = require('through2'); | |
// write beginning of featurecollection | |
process.stdout.write('{"type":"FeatureCollection","features":['); | |
var first = true; | |
process.stdin | |
.pipe(byline.createStream()) | |
.pipe(through2(function(chunk, enc, next){ | |
if (first) process.stdout.write(chunk.toString()); | |
else process.stdout.write(','+chunk.toString()); | |
first = false; | |
next(); | |
})) | |
.on('finish', function(){ | |
process.stdout.write(']}\n'); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment