Public
Edited
Dec 11, 2022
Insert cell
Insert cell
// fs = require('fs');
Insert cell
// ndjson = require('ndjson'); // npm install ndjson
Insert cell
function parseSimplifiedDrawings(fileName, callback) {
var drawings = [];
var fileStream = fs.createReadStream(fileName)
fileStream
.pipe(ndjson.parse())
.on('data', function(obj) {
drawings.push(obj)
})
.on("error", callback)
.on("end", function() {
callback(null, drawings)
});
}

parseSimplifiedDrawings("data/face-simple.ndjson", function(err, drawings) {
if(err) return console.error(err);
drawings.forEach(function(d) {
// Do something with the drawing
console.log(d.key_id, d.countrycode);
})
console.log("# of drawings:", drawings.length);
})
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more