Skip to content
A Node module to parse raw FEC electronic filings, inspired by Fech.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github
lib
test
.drone.yml
.gitignore
.npmignore
LICENSE
README.md
index.js
package-lock.json
package.json

README.md

This 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.

Installation

npm install --save fec-parse

Usage

Parse from downloaded file

wget http://docquery.fec.gov/dcdev/posted/876050.fec
var fs = require('fs'),
    parser = require('fec-parse');

var filingId = '876050'; // Obama for America 2012 post-general report

fs.createReadStream(filingId + '.fec')
            .pipe(parser())
            .on('data', function(row) {
                console.log(row);
            })
            .on('error', function (err) {
                console.error(err);
            })
            .on('finish',function () {
                console.log('done');
            });

Download and parse in one

npm install --save request JSONStream
var fs = require('fs'),
    parser = require('fec-parse'),
    request = require('request'),
    JSONStream = require('JSONStream');

var filingId = '876050';

request('http://docquery.fec.gov/dcdev/posted/' + filingId + '.fec')
    .pipe(parser())
    .pipe(JSONStream.stringify('{"rows":[\n',',\n','\n]}'))
    .pipe(fs.createWriteStream(filingId + '.json'));
You can’t perform that action at this time.