Skip to content

Instantly share code, notes, and snippets.

@tgsuarez
Created September 13, 2017 09:18
Show Gist options
  • Save tgsuarez/95ad37ae0d86a463b4fcedf893edd633 to your computer and use it in GitHub Desktop.
Save tgsuarez/95ad37ae0d86a463b4fcedf893edd633 to your computer and use it in GitHub Desktop.
d3.csv very simple example
license: mit
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<script src="http://d3js.org/d3.v3.min.js"></script>
</head>
<h1 id="output">
</h1>
<script>
var f = "test.csv"
d3.csv(f, function(d) {
return {
Name: d.Name, Surname: d.Surname, Age: d.Age,
};
}, function(error, rows) {
d3.select("#output")
.text(
rows[0].Name + " " +
rows[0].Surname + " " +
"is " + rows[0].Age + " years old")
});
</script>
</html>
Name Surname Age
Joe Smith 42
Alice Jones 29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment