O'Reilly logo

Learning Jupyter by Dan Toomey

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Node.js d3 package

The d3 package has data access functionality. In this case, we will read from a tab-separated file and compute an average. Note the use of the underscore variable name for lodash. Variable names starting with an underscore are assumed to be private, although, in this case, it is just a play on the name of the package we are using, lodash, or underscore. Also, lodash is a widely used utility package.

The script we use is as follows:

var fs = require("fs");
var d3 = require("d3");
var _ = require("lodash");
//read in the animals file
fs.readFile("data/animals.tsv", "utf8", function(error, data) {
    data = d3.tsv.parse(data);
//display on screen
    console.log(JSON.stringify(data));
//compute the maximum weight
 var maxWeight = d3.max(data, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required