A Node module to parse raw FEC electronic filings.
npm install fec-parseThis is an unofficial Node.js parser for electronic filings submitted to the Federal Election Commission.
This uses code from the Fech Ruby gem by Derek Willis and others, and the csv-parser module by Mathias Buus, Max Ogden and others. It uses header mappings contributed to by many and refined by Evan Sonderegger for fecfile.
``shell`
npm i fec-parse
`shell`
wget http://docquery.fec.gov/dcdev/posted/876050.fec
`js
import fs from "fs";
import parser from "fec-parse";
const filingId = "876050"; // Obama for America 2012 post-general report
fs.createReadStream(${filingId}.fec)`
.pipe(parser())
.on("data", (row) => {
console.log(row);
})
.on("error", (err) => {
console.error(err);
})
.on("finish", () => {
console.log("done");
});
`sh`
npm install --save request JSONStream
`js
import fs from "fs";
import parser from "fec-parse";
import request from "request";
import JSONStream from "JSONStream";
const filingId = "876050";
request(http://docquery.fec.gov/dcdev/posted/${filingId}.fec)${filingId}.json
.pipe(parser())
.pipe(JSONStream.stringify('{"rows":[\n', ",\n", "\n]}"))
.pipe(fs.createWriteStream());``