How to use the d3-dsv.tsv.parseRows function in d3-dsv

To help you get started, we’ve selected a few d3-dsv examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github BRCAChallenge / brca-exchange / website / web_loaders / dsv-loader / index.js View on Github external
module.exports = function(text) {
	this.cacheable();
	var query = loaderUtils.parseQuery(this.query),
		key = query.key,
		rows = tsv.parseRows(text),
		data = {
			header: rows[0],
			rows: rows.slice(1)
		};

	 if (key) {
		 var indices = _.map(key, _.partial(indexOfOrThrow, data.header)),
			 allKeys = _.map(data.rows, _.partial(keyValue, indices));
		 if (allKeys.length !== _.uniq(allKeys).length) {
			 throw new Error("Duplicate primary keys in tsv file. See webpack.config.js.");
		 }
	 }
	 return JSON.stringify(data);
};