Giter Club home page Giter Club logo

fec-parse's Introduction

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
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");
  });

Download and parse in one

npm install --save request JSONStream
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`)
  .pipe(parser())
  .pipe(JSONStream.stringify('{"rows":[\n', ",\n", "\n]}"))
  .pipe(fs.createWriteStream(`${filingId}.json`));

fec-parse's People

Contributors

chriszs avatar esonderegger avatar pratheekrebala avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

fec-parse's Issues

v8.3

Hey @chriszs do you plan to support fec v8.3, which is now out? Example filing is 1257392 (though believe everything released now is 8.3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.