Skip to content

Repository files navigation

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 i fec-parse

Usage

Parse from downloaded file

wget http://docquery.fec.gov/dcdev/posted/876050.fec
importfsfrom"fs";importparserfrom"fec-parse";constfilingId="876050";// Obama for America 2012 post-general reportfs.createReadStream(`${filingId}.fec`).pipe(parser()).on("data",(row)=>{console.log(row);}).on("error",(err)=>{console.error(err);}).on("finish",()=>{console.log("done");});

Download and parse in one

npm install --save request JSONStream
importfsfrom"fs";importparserfrom"fec-parse";importrequestfrom"request";importJSONStreamfrom"JSONStream";constfilingId="876050";request(`http://docquery.fec.gov/dcdev/posted/${filingId}.fec`).pipe(parser()).pipe(JSONStream.stringify('{"rows":[\n',",\n","\n]}")).pipe(fs.createWriteStream(`${filingId}.json`));

About

A Node module to parse raw FEC electronic filings, inspired by Fech.

Topics

Resources

Stars

19 stars

Watchers

1 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages