Skip to content

API

__version__ module-attribute

__version__ = _version.get_version()

Version string for this package.

FecFile

FecFile(src: str | os.PathLike) -> None

An FEC file.

This doesn't do any reading or parsing until you access one of the members.

Parameters:

Name Type Description Default
src str | os.PathLike

A path or a URL to an FEC file. If a string that starts with "http://" or "https://", it will be treated as a URL. Otherwise, it will be treated as a path.

required

cover cached property

cover: Cover

The Cover of the FEC file.

The first time this is accessed, the FEC file will be read and parsed as far as needed. Subsequent accesses will return the same object.

header cached property

header: Header

The Header of the FEC file.

The first time this is accessed, the FEC file will be read and parsed as far as needed. Subsequent accesses will return the same object.

to_csvs

to_csvs(out_dir: str | os.PathLike) -> None

Write all itemizations in this FEC file to CSV files.

There will be one CSV file for each record type, eg. sa11.csv.

to_parquets

to_parquets(out_dir: str | os.PathLike) -> None

Write all itemizations in this FEC file to parquet files.

There will be one parquet file for each record type, eg. sa11.parquet.

Header

Bases: NamedTuple

The header of a FecFile.

Attributes:

Name Type Description
fec_version str

The version of the FEC file format.

software_name str

The name of the software that generated the file.

software_version str | None

The version of the software that generated the file. This isn't present in some older FEC files.

report_id str | None

If this .fec file is an amendment to a previous filing, the filing number of the original.

report_number str | None

If this .fec file is an amendment to a previous filing, which number amendement this is (1, 2, 3 etc)

Cover

Bases: NamedTuple

The Cover Line of an FecFile.

Attributes:

Name Type Description
form_type str

The form type of the filing, eg. "F3"

filer_committee_id str

The FEC-assigned ID of the committee that filed the report, eg "C00618371"

ItemizationBatch

Bases: NamedTuple

A batch of itemizations.

Attributes:

Name Type Description
code str

The code of the itemization type, eg. "SA11AI"

records pa.RecordBatch

A pyarrow.RecordBatch of itemizations.

PyarrowBatcher

PyarrowBatcher(
    fec_file: FecFile, max_batch_size: int | None = None
) -> None

Iterates an FecFile and yields ItemizationBatchs of itemizations.

Parameters:

Name Type Description Default
fec_file FecFile

The FecFile to iterate.

required
max_batch_size int | None

The max rows per pyarrow.RecordBatch. Defaults to 1024 * 1024, which is what rust parquet uses.

None

__next__

__next__() -> ItemizationBatch

Get the next batch of itemizations from the FEC file.