Package for dealing with TEC reports
Project description
Python code for interacting with Texas Ethics Commission reports
Installation & Configuration
You can install this using pip like this:
pip install tx_tecreports
Now you’re ready to start using tx_tecreports.
Usage
tx_tecreports parses campaign finance reports from the Texas Ethics Commission. You use the tx_tecreports.fetcher.get_report like this.
>>> from tx_tecreports.fetcher import get_report
You can fetch any report so long as you have the correct ID. For example, you could grab Wendy Davis’ first special session report (the first one filed after her filibuster) with the ID 581606. You can find that ID by visiting her filer page on the Texas Ethics Commission website.
>>> report = get_report(581606)
Now you can interact with the various data in the cover element via report.cover.
>>> report.cover.type_of_filing
'COH-SS'
>>> report.cover.is_original
True
>>> report.cover.through_date - report.cover.from_date
datetime.timedelta(29)
You can verify that this is her personal filing by seeing that the filer_type is a IND:
>>> report.cover.filer.filer_type
'IND'
The really interesting data is in the receipts property, a list of all of the contributions received in this report. For example, you can see how many contributions where made by looking at its length:
>>> len(report.receipts)
1240
You can create a list of all of the contributions on any given day with by looking at the contribution.date like this:
>>> len([a for a in report.receipts if a.contribution.date == report.cover.from_date])
0
Oops, looks like she didn’t have any contributions on the first day of that report. Let’s change it to the last day:
>>> len([a for a in report.receipts if a.contribution.date == report.cover.through_date])
1187
That’s more like it!
TODO: Flesh out this example as part of the narrative text
>>> from tx_tecreports.fetcher import get_filings_list
>>> filings = get_filings_list("00062095COH")
>>> len(filings) >= 33 # Has 33 filings as of January 2014
True
>>> report = filings[-1].report
>>> len(report.receipts)
157
>>> report.total_receipts
279284.94
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file tx_tecreports-0.8.1.tar.gz
.
File metadata
- Download URL: tx_tecreports-0.8.1.tar.gz
- Upload date:
- Size: 105.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad080fe38b36e009680137586e6ce67a55e1d2d2fd373196fd261b9022fd548a |
|
MD5 | 46d7834314bc5feb190439dd3c68af3f |
|
BLAKE2b-256 | 9d51ecd04f5b781e835c62e1206b58fec9300a8c356edd80eb4fc273657fd672 |