Published
Edited
Mar 27, 2022
7 stars
Insert cell
Insert cell
Insert cell
fecParser = require("fec-parse@0.26.0")
Insert cell
Insert cell
fecFiling = 'https://docquery.fec.gov/dcdev/posted/1358932.fec'
Insert cell
Insert cell
db = {
const db = await FileAttachment("fec.db").sqlite();
let inserts = [];
const parse = fecParser().on("data", (row) =>
inserts.push(insertRow(db, row))
);
const decoder = new TextDecoder("utf-8");
const reader = (await fetch(proxy(fecFiling))).body.getReader();
let done, value;
while ((({ done, value } = await reader.read()), !done)) {
parse.write(decoder.decode(value, { stream: true }));
}
parse.end();
await Promise.all(inserts);
return db;
}
Insert cell
Insert cell
db
SELECT form_type,
filer_committee_id_number,
committee_name,
col_a_total_receipts,
col_a_total_disbursements
FROM fec_presidential_summaries;
Insert cell
db
SELECT contributor_last_name,
contributor_first_name,
contributor_city,
contributor_state,
contribution_date,
contribution_amount
FROM fec_contributions
WHERE memo_code IS NULL
ORDER BY contribution_amount DESC
LIMIT 20;
Insert cell
db
SELECT contributor_city,
count(*)
FROM fec_contributions
WHERE memo_code IS NULL
GROUP BY contributor_city
ORDER BY count(*) DESC
LIMIT 10;
Insert cell
Insert cell
proxy = url => `https://zubakskees-cors-proxy.herokuapp.com/${url}`
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more