Skip to main content
100%

Loading US Election CSV Data

✓ Published0🌍 Public
PPeter VanNostrand
Last edited Sep 28, 2021
Created on Sep 8, 2021

This example demonstrates how to load and summarize US House election data from 2008 to 2020, displaying the file size, row count, and column count in a large HTML text element. It uses `d3.csv` to fetch and parse the remote CSV file, leveraging the promise-based `.then()` method to process the parsed data. The code also includes commented-out alternatives using `fetch` with `async/await` and `d3.csvParse`, as well as a nested promise pattern, showing multiple approaches for handling asynchronous data loading in D3 v5.

AI-generated description

A program that loads and parses some CSV data

Data Source: US House Elections Data 2008-2020.

This dataset contains the election results for all US house seats from 2008 to 2020. Relevant features include the year, state, district, candidate name, party, the votes for that candidate, and the total number of votes in the district.

MIT Licensed

Similar vizzes