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, ...
Get Learning Jupyter now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.