Search⌘ K
AI Features

Formatting Data From a CSV

Learn to format data from a CSV file for use in Sankey diagrams with D3.js. This lesson guides you through transforming CSV entries into nodes and links, using D3.js functions to process and nest data properly. Gain hands-on skills to prepare data for effective Sankey visualizations.

From a CSV with ‘source,’ ‘target,’ and ‘value’ info only

Using a CSV file (in this case, called sankey.csv) that looks like this:

source,target,value
Barry,Elvis,2
Frodo,Elvis,2
Frodo,Sarah,2
Barry,Alice,2
Elvis,Sarah,2
Elvis,Alice,2
Sarah,Alice,4

We take this single line from our original Sankey diagram code:

 ...