import { select, csv, csvFormat } from 'd3';
const kilobytes = data => Math.ceil(csvFormat(data).length / 1024);
const body = select('body');
csv('data.csv').then(data => {
body
.append('pre')
.text([
${data.length} rows
,
${Object.keys(data[0]).length} columns
,
${kilobytes(data)} KB
].join(', '));
body .append('pre') .text('First 10 rows:');
body .append('pre') .text(JSON.stringify(data.slice(0, 10), null, 2)); });