Export Image
Export Code

Untitled

JamesHop31

Last edited Jun 02, 2022
Created on Jun 02, 2022
Forked from dataset#2

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)); });

MIT Licensed