├── .github └── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── custom.md │ └── feature_request.md ├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── PULL_REQUEST_TEMPLATE.md ├── README.md ├── docs ├── _layouts │ └── default.html ├── apple-touch-icon.png ├── changelog.md ├── css │ └── fecfile.css ├── favicon-16x16.png ├── favicon-32x32.png ├── favicon.ico └── index.md ├── fecfile ├── __init__.py ├── cache.py ├── fecparser.py ├── mappings.json └── types.json ├── setup.py ├── speedtests.py ├── test-data ├── 1162172.fec ├── 1229017.fec ├── 1236235.fec ├── 1260488.fec ├── 1385191.fec ├── 20180616.zip └── 27789.fec └── tests.py /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | labels: 5 | 6 | --- 7 | 8 | **Describe the bug** 9 | A clear and concise description of what the bug is. 10 | 11 | **To Reproduce** 12 | Steps to reproduce the behavior: 13 | 1. Try to parse file number '...' 14 | 2. Look for '....' in parsed results 15 | 3. See error 16 | 17 | **Expected behavior** 18 | A clear and concise description of what you expected to happen. 19 | 20 | **Environment** 21 | What version of python you're running (optional) 22 | 23 | **Additional context** 24 | Add any other context about the problem here. 25 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/custom.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Custom issue template 3 | about: Describe this issue template's purpose here. 4 | labels: 5 | 6 | --- 7 | 8 | 9 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | labels: 5 | 6 | --- 7 | 8 | **Is your feature request related to a problem? Please describe.** 9 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 10 | 11 | **Describe the solution you'd like** 12 | A clear and concise description of what you want to happen. 13 | 14 | **Describe alternatives you've considered** 15 | A clear and concise description of any alternative solutions or features you've considered. 16 | 17 | **Additional context** 18 | Add any other context or screenshots about the feature request here. 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | MANIFEST 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | .pytest_cache/ 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | local_settings.py 57 | db.sqlite3 58 | 59 | # Flask stuff: 60 | instance/ 61 | .webassets-cache 62 | 63 | # Scrapy stuff: 64 | .scrapy 65 | 66 | # Sphinx documentation 67 | docs/_build/ 68 | 69 | # PyBuilder 70 | target/ 71 | 72 | # Jupyter Notebook 73 | .ipynb_checkpoints 74 | 75 | # pyenv 76 | .python-version 77 | 78 | # celery beat schedule file 79 | celerybeat-schedule 80 | 81 | # SageMath parsed files 82 | *.sage.py 83 | 84 | # Environments 85 | .env 86 | .venv 87 | env/ 88 | venv/ 89 | ENV/ 90 | env.bak/ 91 | venv.bak/ 92 | 93 | # Spyder project settings 94 | .spyderproject 95 | .spyproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | # mkdocs documentation 101 | /site 102 | 103 | # mypy 104 | .mypy_cache/ 105 | 106 | # OSX 107 | .DS_Store 108 | 109 | # Github pages 110 | docs/_site 111 | docs/Gemfile* 112 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, sex characteristics, gender identity and expression, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at evan@rpy.xyz. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 72 | 73 | [homepage]: https://www.contributor-covenant.org 74 | 75 | For answers to common questions about this code of conduct, see 76 | https://www.contributor-covenant.org/faq 77 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Thank you so much for helping out with this library! Working with campaign finance data can be challenging and I think we're all better off when we view low-level details like parsing raw files into native data structures for commonly-used languages as a group effort. 4 | 5 | I suspect GitHub is encouraging the creation of contribution guidelines due to popular repositories where the volume of contibution overwhelms the maintainers. Thankfully this library does not have that problem. 6 | 7 | There really are no right and wrong ways to contribute. Creating a new issue here to ask a question is perfectly acceptable and could hopefully help future users who might have the same question. If the library doesn't behave as expected, hopefully the issue templates can help guide explaining how the actual behavior differed from the expected behavior. If you prefer, I'm happy to respond to questions and suggestions via email. If you happen to be a member of the [News Nerdery](https://newsnerdery.org/) Slack, I'm happy to chat about the library via direct message or about campaign finance data in general in the `#campfin` channel. 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | (Please feel free to delete this template if it doesn't apply - only use it if it's helpful) 2 | 3 | * **What kind of change does this PR introduce?** (Bug fix, feature, docs update, ...) 4 | 5 | 6 | 7 | * **What is the current behavior?** (You can also link to an open issue here) 8 | 9 | 10 | 11 | * **What is the new behavior (if this is a feature change)?** 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # fecfile 2 | A python parser for the .fec file format 3 | 4 | This is a library for converting campaign finance filings stored in the .fec format into native python objects. It maps the comma/ASCII 28 delimited fields to canonical names based on the version the filing uses and then converts the values that are dates and numbers into the appropriate `int`, `float`, or `datetime` objects. 5 | 6 | This library is in relatively early testing. I've used it on a couple of projects, but I wouldn't trust it to work on all filings. That said, if you do try using it, I'd love to hear about it! 7 | 8 | ## Why? 9 | The FEC makes a ton of data available via the "export" links on the main site and the [developer API](https://api.open.fec.gov/developers/). For cases where those data sources are sufficient, they are almost certainly the easiest/best way to go. A few cases where one might need to be digging into raw filings are: 10 | 11 | - Getting information from individual itemizations including addresses. (The FEC doesn't include street addresses in bulk downloads.) 12 | - Getting data as soon as it has been filed, instead of waiting for it to be coded. (The FEC generally codes all filings received by 7pm eastern by 7am the next day. However, that means that a filing received at 11:59pm on Monday wouldn't be available until 7am on Wednesday, for example.) 13 | - Getting more data than the rate-limit on the developer API would allow. 14 | - Maintaining one's own database with all relevant campaign finance data, perhaps synced with another data source. 15 | 16 | Raw filings can be found by either downloading the [bulk data](https://www.fec.gov/data/advanced/?tab=bulk-data) zip files or from http requests like [this](https://docquery.fec.gov/dcdev/posted/1229017.fec). This library includes helper methods for both. 17 | 18 | ## Installation 19 | To get started, install from [pypi](https://pypi.org/project/fecfile/) by running the following command in your preferred terminal: 20 | 21 | ```shell 22 | pip install fecfile 23 | ``` 24 | 25 | ## Usage 26 | For the vast majority of filings, the easiest way to use this library will be to load filings all at once by using the `from_http(file_number)`, `from_file(file_path)`, or `loads(input)` methods. 27 | 28 | These methods will return a Python dictionary, with keys for `header`, `filing`, `itemizations`, and `text`. The `itemizations` dictionary contains lists of itemizations grouped by type (`Schedule A`, `Schedule B`, etc.). 29 | 30 | ### Examples: 31 | 32 | ```python 33 | import fecfile 34 | import requests 35 | 36 | filing1 = fecfile.from_file('1690664.fec') 37 | print('${:,.2f}'.format(filing1['filing']['col_a_total_receipts'])) 38 | 39 | filing2 = fecfile.from_http(1690664) 40 | print(filing2['filing']['committee_name']) 41 | 42 | filing3 = fecfile.from_http(1690664) 43 | all_contributions = filing3['itemizations']['Schedule A'] 44 | mid_size_contributions = [item for item in all_contributions if 500 <= item['contribution_amount'] < 1000] 45 | print(len(mid_size_contributions)) 46 | 47 | with open('1690664.fec') as file: 48 | parsed = fecfile.loads(file.read()) 49 | num_disbursements = len(parsed['itemizations']['Schedule B']) 50 | print(num_disbursements) 51 | 52 | url = 'https://docquery.fec.gov/dcdev/posted/1690664.fec' 53 | r = requests.get(url, headers={'User-Agent': 'Mozilla/5.0'}) 54 | parsed = fecfile.loads(r.text) 55 | fecfile.print_example(parsed) 56 | ``` 57 | 58 | Note: the docquery.fec.gov urls cause problems with the requests library when a user-agent is not supplied. There may be a cleaner fix to that though. 59 | 60 | ## Advanced Usage 61 | 62 | FEC filings can be arbitrarily large. Loading enormous filings into memory all at once can cause problems (including running out of memory). 63 | 64 | The `fecfile` library exposes the `iter_file` and `iter_http` methods to read large filings one line at a time. Both are generator functions that yield `FecItem` objects, which consist of `data` and `data_type` attributes. The data_type attribute can be one of "header", "summary", "itemization", "text", or "F99_text". The data attribute is a dictionary for all data types except for "F99_text", for which it is a string. 65 | 66 | ```python 67 | import fecfile 68 | import imaginary_database 69 | 70 | # Sometimes we only care about summary data, but want to be able to handle all filings, without 71 | # knowing anything about them before we attempt to parse. 72 | no_itemizations = {'filter_itemizations': []} 73 | for i in range(1300000, 1320000): 74 | for item in fecfile.iter_http(i, options=no_itemizations): 75 | if item.data_type == 'summary': 76 | imaginary_database.add_to_db(item.data) 77 | 78 | # Sometimes we only care about one type of itemization, but from a very large filing. 79 | # In this example, we add up all the contributions from Delaware in ActBlue's 2018 80 | # post-general filing 81 | only_contributions = {'filter_itemizations': ['SA']} 82 | de_total = 0 83 | for item in fecfile.iter_http(1300352, options=only_contributions): 84 | if item.data_type == 'itemization': 85 | if item.data['contributor_state'] == 'DE': 86 | de_total += item.data['contribution_amount'] 87 | print(de_total) 88 | 89 | # Sometimes we want to maintain a database where different types of itemizations live in their own 90 | # tables and have foreign key relationships to a summary record. 91 | file_path = '/path/to/99840.fec' 92 | filing = None 93 | for item in fecfile.iter_file(file_path): 94 | if item.data_type == 'summary': 95 | filing = imaginary_database.add_filing(file_number=99840, **item.data) 96 | if item.data_type == 'itemization': 97 | if item.data['form_type'].startswith('SA'): 98 | imaginary_database.add_contribution(filing=filing, **item.data) 99 | if item.data['form_type'].startswith('SB'): 100 | imaginary_database.add_disbursement(filing=filing, **item.data) 101 | if item.data['form_type'].startswith('SC'): 102 | imaginary_database.add_loan(filing=filing, **item.data) 103 | ``` 104 | 105 | You can also choose to use the `parse_header` and `parse_line` methods if you are implementing a different method of 106 | iterating over a filing's content. Before version 0.6, the below example was the only way to use `fecfile` to parse 107 | filings without loading the entire filing into memory. This approach should no longer be necessary, but is kept to 108 | show how example usage for those methods. 109 | 110 | ```python 111 | import fecfile 112 | 113 | version = None 114 | 115 | with open('1263179.fec') as file: 116 | for line in file: 117 | if version is None: 118 | header, version = fecfile.parse_header(line) 119 | else: 120 | parsed = fecfile.parse_line(line, version) 121 | save_to_db(parsed) 122 | ``` 123 | 124 | 125 | ## API Reference 126 | 127 |

loads

128 | 129 | ```python 130 | loads(input, options={}) 131 | ``` 132 | Deserialize ``input`` (a ``str`` instance 133 | containing an FEC document) to a Python object. 134 | 135 | Optionally, pass an array of strings to ``options['filter_itemizations']``. 136 | If included, ``loads`` will only parse lines that start with any of the 137 | strings in that array. For example, passing 138 | ``{'filter_itemizations': ['SC', 'SD']}`` to ``options``, will only include 139 | Schedule C and Schedule D itemizations. Also, passing 140 | ``{'filter_itemizations': []}`` to ``options`` will result in only the header 141 | and the filing being parsed and returned. 142 | 143 | Including `{'as_strings': True}` in the `options` dictionary will not attempt to convert values that are normally numeric or datetimes to their native python types and will return dictionaries with all values as strings. 144 | 145 |

parse_header

146 | 147 | ```python 148 | parse_header(hdr) 149 | ``` 150 | Deserialize a ``str`` or a list of ``str`` instances containing 151 | header information for an FEC document. Returns an Python object, the 152 | version ``str`` used in the document, and the number of lines used 153 | by the header. 154 | 155 | The third return value from parse_header--the number of lines used by the header--is only 156 | useful for early versions of the FEC file format, typically predating 2001. Versions 1 and 2 of the FEC file format allowed headers to be a multiline string beginning and ending with ``/*``. 157 | 158 | Returning the number of lines in the header allows us to know where the non-header lines begin. 159 | 160 |

parse_line

161 | 162 | ```python 163 | parse_line(line, version, line_num=None) 164 | ``` 165 | Deserialize a ``line`` (a ``str`` instance 166 | containing a line from an FEC document) to a Python object. 167 | 168 | ``version`` is a ``str`` instance for the version of the FEC file format 169 | to be used, and is required. 170 | 171 | ``line_num`` is optional and is used for debugging. If an error or 172 | warning is encountered, whatever is passed in to ``line_num`` will be 173 | included in the error/warning message. Normally the line number of the input file will be passed in, so that the user is shown the error and the line number in the original file that triggered the error. 174 | 175 |

from_http

176 | 177 | ```python 178 | from_http(file_number, options={}) 179 | ``` 180 | Utility method for retrieving a parsed Python representation of an FEC 181 | filing when it is not available as a local file. This method takes 182 | either a ``str`` or ``int`` as a ``file_number`` and requests the corresponding filing from 183 | the ``docquery.fec.gov`` server. It returns the parsed response. 184 | 185 | See [above](#fecfile.loads) for how documentation on how to use the optional 186 | ``options`` argument. 187 | 188 |

from_file

189 | 190 | ```python 191 | from_file(file_path, options={}) 192 | ``` 193 | Utility method for getting a parsed Python representation of an FEC 194 | filing that exists as a .fec file on a local machine. This method takes 195 | a ``str`` of the path to the file, and returns the parsed Python object. 196 | 197 | See [above](#fecfile.loads) for how documentation on how to use the optional 198 | ``options`` argument. 199 | 200 |

iter_http

201 | 202 | ```python 203 | iter_http(file_number, options={}) 204 | ``` 205 | Makes an http request for the given `file_number` and iterates over the response, yielding `FecItem` instances, which consist of `data` and `data_type` attributes. The `data_type` attribute can be one of "header", "summary", "itemization", "text", or "F99_text". The `data` attribute is a dictionary for all data types except for "F99_text", for which it is a string. This method avoids loading the entire filing into memory, as the `from_http` method does. 206 | 207 | See [above](#fecfile.loads) for how documentation on how to use the optional 208 | ``options`` argument. 209 | 210 |

iter_file

211 | 212 | ```python 213 | iter_file(file_path, options={}) 214 | ``` 215 | Opens a file at the given `file_path` and iterates over its contents, yielding `FecItem` instances, which consist of `data` and `data_type` attributes. The `data_type` attribute can be one of "header", "summary", "itemization", "text", or "F99_text". The `data` attribute is a dictionary for all data types except for "F99_text", for which it is a string. This method avoids loading the entire filing into memory, as the `from_file` method does. 216 | 217 | See [above](#fecfile.loads) for how documentation on how to use the optional 218 | ``options`` argument. 219 | 220 |

print_example

221 | 222 | ```python 223 | print_example(parsed) 224 | ``` 225 | Utility method for debugging - prints out a representative subset of 226 | the Python object returned by one of the deserialization methods. For 227 | filings with itemizations, it only prints the first of each type of 228 | itemization included in the object. 229 | 230 | 231 | ## Developing locally 232 | 233 | Assuming you already have Python3 and the ability to create virtual environments installed, first clone this repository from github and cd into it: 234 | 235 | ```shell 236 | git clone https://github.com/esonderegger/fecfile.git 237 | cd fecfile 238 | ``` 239 | 240 | Then create a virtual environment for this project (I use the following commands, but there are several ways to get the desired result): 241 | 242 | ```shell 243 | python3 -m venv venv 244 | source venv/bin/activate 245 | ``` 246 | 247 | Next, install the dependencies: 248 | 249 | ```shell 250 | python setup.py install 251 | ``` 252 | 253 | Finally, make some changes, and run: 254 | 255 | ```shell 256 | python tests.py 257 | ``` 258 | 259 | ## Thanks 260 | 261 | This project would be impossible without the work done by the kind folks at The New York Times [Newsdev team](https://github.com/newsdev). In particular, this project relies heavily on [fech](https://github.com/NYTimes/Fech). 262 | 263 | Many thanks to [Derek Willis](https://github.com/dwillis) for creating and maintaining [fech-sources](https://github.com/dwillis/fech-sources) which serves as the upstream source of truth for parsing libaries in various languages. 264 | 265 | A huge thank you to [Chris Zubak-Skees](https://github.com/chriszs), whose work on the [fec-parse](https://github.com/PublicI/fec-parse) javascript library inspired this project. 266 | 267 | Many thanks to [Jacob Fenton](https://github.com/jsfenfen) for writing the caching logic and for providing valuable feedback about the overall design of this library. 268 | 269 | ## Contributing 270 | 271 | I would love some help with this, particularly with the mapping from strings to `int`, `float`, and `datetime` types. Please [create an issue](https://github.com/esonderegger/fecfile/issues) or [make a pull request](https://github.com/esonderegger/fecfile/pulls). Or reach out privately via email - that works too. 272 | 273 | ## To do: 274 | 275 | Almost too much to list: 276 | 277 | - ~~Handle files from before v6 when they were comma-delimited~~ 278 | - create a `dumps` method for writing .fec files for round-trip tests 279 | - add more types to the types.json file 280 | - elegantly handle errors 281 | 282 | ## Changes 283 | 284 | See the [changelog](https://esonderegger.github.io/fecfile/changelog.html) for a list of notable changes introduced in each version of fecfile. -------------------------------------------------------------------------------- /docs/_layouts/default.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {{ page.title }} 6 | 7 | 8 | 9 | 10 | 11 | {{ content }} 12 | 13 | -------------------------------------------------------------------------------- /docs/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/esonderegger/fecfile/0ac4f0372d4eddedd6bde850cd73c092a5ffc76b/docs/apple-touch-icon.png -------------------------------------------------------------------------------- /docs/changelog.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: A list of changes in each version of fecfile 4 | --- 5 | 6 | # Changelog 7 | 8 | A list of changes in each version of fecfile 9 | 10 | ### 0.9.1 (May 3, 2025) 11 | - Add mappings for F3PZ1 and F3PZ2 12 | 13 | ### 0.9.0 (April 23, 2025) 14 | - add support for version 8.5 15 | 16 | ### 0.8.0 (February 25, 2023) 17 | - add some missing mappings from v5 of F3 18 | 19 | ### 0.7.2 (July 23, 2022) 20 | - fix mappings for version 8.4 of F5 21 | 22 | ### 0.7.1 (July 16, 2022) 23 | - fix mappings for version 8.4 of F3Z1 and F3Z2 24 | 25 | ### 0.7.0 (May 17, 2022) 26 | - add support for version 8.4 27 | - fix for version 2 of schedule A 28 | - fix for `UnicodeDecodeError` 29 | 30 | ### 0.6.4 (September 3, 2020) 31 | - add date types to schedule C 32 | - include status code with error from `iter_http` 33 | 34 | ### 0.6.3 (June 3, 2019) 35 | - use https for docquery.fec.gov URLs 36 | 37 | ### 0.6.2 (April 24, 2019) 38 | - add mappings and types for F8, F82, and F83 39 | - edits to documentation 40 | 41 | ### 0.6.1 (April 11, 2019) 42 | - add mappings and types for F10 and F105 43 | - add as_strings option to disable typing process 44 | - raise exception when requests for a given file number do not succeed 45 | 46 | ### 0.6.0 (April 10, 2019) 47 | - add iter_http and iter_file functions, using a shared iter_lines function 48 | - refactor loads to use the new generator functions for performance 49 | 50 | ### 0.5.3 (February 12, 2019) 51 | - handle trailing whitespace in form_type field 52 | - fix regex for F1M 53 | - fix F5 for P3.2 and P3.3 54 | 55 | ### 0.5.2 (January 19, 2019) 56 | - add Form 1 mappings for version 2 57 | - add Schedule F mappings for version 2 58 | - update mappings regexes for F6 and F65 59 | - add H4 mappings for version 2 60 | - add H3 mappings for version 2 61 | 62 | ### 0.5.1 (January 18, 2019) 63 | - update mappings versions for F3Z 64 | - add mappings and types for schedule I 65 | - allow filtering of itemizations for comma-delimited filings 66 | 67 | ### 0.5.0 (January 17, 2019) 68 | - add ability to filter which types of itemizations to parse 69 | - cache mappings and types for much faster parsing 70 | 71 | ### 0.4.11 (January 12, 2019) 72 | - handle files encoded in Windows 1252 73 | - fix for duplicate col_b_transfers_from_affiliated mapping 74 | - allow for form F4T 75 | 76 | ### 0.4.10 (November 7, 2018) 77 | - strip whitespace when parsing values as float or date 78 | - fix mis-mapped field in paper F3 filings 79 | 80 | ### 0.4.9 (November 6, 2018) 81 | - add mappings for paper versions of F24 82 | 83 | ### 0.4.8 (November 6, 2018) 84 | - fix v5/3 mapping for F3P to include v1 and v2 85 | - make F5 mappings more explicit and include v6.1 86 | - add types for F3S 87 | 88 | ### 0.4.7 (November 2, 2018) 89 | - add types for F4, SF, and SL 90 | - fix issue causing incorrect mapping for F9 91 | 92 | ### 0.4.6 (October 29, 2018) 93 | - add mappings for paper versions of F4 94 | - add mappings for paper versions of F56 95 | - add mappings for paper versions of F91 96 | - add mappings for paper versions of F92 97 | - add mappings for paper versions of F93 98 | - add mappings for paper versions of F94 99 | - add mappings for paper versions of F99 100 | - add mappings for paper versions of H5 and H6 101 | - add mappings for paper versions of Schedule L 102 | - add mapping for version P3.4 for F3Z1 and F3Z2 103 | 104 | ### 0.4.5 (October 27, 2018) 105 | - add mappings for paper versions of F3Z 106 | 107 | ### 0.4.4 (October 17, 2018) 108 | - fixed out of order mappings for paper versions of F3 109 | 110 | ### 0.4.3 (October 10, 2018) 111 | - add mappings for paper versions of F76 112 | - add mappings for paper versions of F9 113 | - add mappings for paper versions of F2 114 | - add mappings for paper versions of F7 115 | 116 | ### 0.4.2 (October 9, 2018) 117 | - add mappings for paper versions of F57 118 | - add mappings for paper versions of F5 119 | - add mappings for paper versions of F3L 120 | - add mappings for paper versions of F3S 121 | 122 | ### 0.4.1 (October 4, 2018) 123 | - add mappings for versions P1 and P2 of Schedule B 124 | - add mappings for versions P1 and P2 of Schedule A 125 | - add mappings for versions P1 and P2 of F3 126 | - add F99_text field to returned object for form 99 filings 127 | - add hdr mappings for paper versions 1 and 2 128 | - do not split on commas when we know the form is using ascii 28 129 | - add mappings for paper versions of F65 130 | - add mappings for paper versions of schedule C1 131 | - add mappings for paper versions of schedule C2 132 | - add mappings for paper versions of schedule E 133 | 134 | ### 0.4.0 (October 2, 2018) 135 | - Updated documentation 136 | - add paper versions for schedule F 137 | 138 | ### 0.3.9 (October 1, 2018) 139 | - add paper versions for H1, H2, H3, and H4 140 | 141 | ### 0.3.8 (September 28, 2018) 142 | - add paper versions for the F1S 143 | 144 | ### 0.3.7 (September 27, 2018) 145 | - add paper versions of F1M 146 | - add paper versions for F3X 147 | - add F3P paper filing mappings 148 | 149 | ### 0.3.6 (September 27, 2018) 150 | - add F6 paper mappings and fix missing commas 151 | 152 | ### 0.3.5 (September 26) 153 | - add all paper versions of form F1 154 | 155 | ### 0.3.4 (September 18, 2018) 156 | - expose parse_header and parse_line to consumers of this library 157 | 158 | ### 0.3.3 (September 18, 2018) 159 | - add version 8.3 to mappings 160 | 161 | ### 0.3.2 (August 29, 2018) 162 | - versions 1 and 2 of schedule H1 and H2 163 | 164 | ### 0.3.1 (August 29, 2018) 165 | - added more mappings 166 | - add a method to determine which mappings are missing 167 | 168 | ### 0.3.0 (August 27, 2018) 169 | - Rework warnings and errors for cases where mappings are missing 170 | - add mappings 171 | 172 | ### 0.2.3 (August 24, 2018) 173 | - fix for filings that use both quotes and the field separator 174 | 175 | ### 0.2.2 (August 23, 2018) 176 | - add support for F13, F132, and F133 177 | 178 | ### 0.2.1 (August 21, 2018) 179 | - Fix regression that broke paper filings 180 | 181 | ### 0.2.0 (August 2, 2018) 182 | - Add parsing for versions 1 and 2 of the .fec format 183 | 184 | ### 0.1.9 (July 18, 2018) 185 | - add parsing for senate paper filings 186 | 187 | ### 0.1.8 (June 26, 2018) 188 | - interest rate should never have been a float field 189 | 190 | ### 0.1.7 (June 26, 2018) 191 | - handle n/a in number fields 192 | 193 | ### 0.1.6 (June 25, 2018) 194 | - more types 195 | - update documentation 196 | - handle percent signs in interest rates 197 | 198 | ### 0.1.5 (June 21, 2018) 199 | - Initial published version 200 | -------------------------------------------------------------------------------- /docs/css/fecfile.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-size: 18px; 3 | font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; 4 | font-weight: 300; 5 | margin: 1em 2em; 6 | line-height: 1.5; 7 | color: #444; 8 | } 9 | h1, h2, h3 { 10 | line-height: 1.2; 11 | max-width: 40rem; 12 | margin: 1.25em auto 0; 13 | } 14 | p, ul { 15 | max-width: 40rem; 16 | margin: 1em auto; 17 | } 18 | a { 19 | color: #268bd2; 20 | } 21 | 22 | pre { 23 | background-color: #002b36; 24 | border-radius: .75em; 25 | color: #93a1a1; 26 | font-size: .9em; 27 | max-width: 42em; 28 | overflow-x: auto; 29 | margin: 1em auto; 30 | padding: 1em; 31 | } 32 | 33 | .highlight .c { color: #759299; } 34 | .highlight .err { color: #93a1a1; } 35 | .highlight .g { color: #93a1a1; } 36 | .highlight .k { color: #859900; } 37 | .highlight .l { color: #93a1a1; } 38 | .highlight .n { color: #93a1a1; } 39 | .highlight .o { color: #859900; } 40 | .highlight .x { color: #e9662f; } 41 | .highlight .p { color: #93a1a1; } 42 | .highlight .cm { color: #759299; } 43 | .highlight .cp { color: #859900; } 44 | .highlight .c1 { color: #759299; } 45 | .highlight .cs { color: #859900; } 46 | .highlight .gd { color: #2aa198; } 47 | .highlight .ge { color: #93a1a1; font-style: italic; } 48 | .highlight .gr { color: #e8625f; } 49 | .highlight .gh { color: #e9662f; } 50 | .highlight .gi { color: #859900; } 51 | .highlight .go { color: #93a1a1; } 52 | .highlight .gp { color: #93a1a1; } 53 | .highlight .gs { color: #93a1a1; font-weight: bold; } 54 | .highlight .gu { color: #e9662f; } 55 | .highlight .gt { color: #93a1a1; } 56 | .highlight .kc { color: #e9662f; } 57 | .highlight .kd { color: #3294da; } 58 | .highlight .kn { color: #859900; } 59 | .highlight .kp { color: #859900; } 60 | .highlight .kr { color: #3294da; } 61 | .highlight .kt { color: #e8625f; } 62 | .highlight .ld { color: #93a1a1; } 63 | .highlight .m { color: #2aa198; } 64 | .highlight .s { color: #2aa198; } 65 | .highlight .na { color: #93a1a1; } 66 | .highlight .nb { color: #B58900; } 67 | .highlight .nc { color: #3294da; } 68 | .highlight .no { color: #e9662f; } 69 | .highlight .nd { color: #3294da; } 70 | .highlight .ni { color: #e9662f; } 71 | .highlight .ne { color: #e9662f; } 72 | .highlight .nf { color: #3294da; } 73 | .highlight .nl { color: #93a1a1; } 74 | .highlight .nn { color: #93a1a1; } 75 | .highlight .nx { color: #93a1a1; } 76 | .highlight .py { color: #93a1a1; } 77 | .highlight .nt { color: #3294da; } 78 | .highlight .nv { color: #3294da; } 79 | .highlight .ow { color: #859900; } 80 | .highlight .w { color: #93a1a1; } 81 | .highlight .mf { color: #2aa198; } 82 | .highlight .mh { color: #2aa198; } 83 | .highlight .mi { color: #2aa198; } 84 | .highlight .mo { color: #2aa198; } 85 | .highlight .sb { color: #759299; } 86 | .highlight .sc { color: #2aa198; } 87 | .highlight .sd { color: #93a1a1; } 88 | .highlight .s2 { color: #2aa198; } 89 | .highlight .se { color: #e9662f; } 90 | .highlight .sh { color: #93a1a1; } 91 | .highlight .si { color: #2aa198; } 92 | .highlight .sx { color: #2aa198; } 93 | .highlight .sr { color: #e8625f; } 94 | .highlight .s1 { color: #2aa198; } 95 | .highlight .ss { color: #2aa198; } 96 | .highlight .bp { color: #3294da; } 97 | .highlight .vc { color: #3294da; } 98 | .highlight .vg { color: #3294da; } 99 | .highlight .vi { color: #3294da; } 100 | .highlight .il { color: #2aa198; } 101 | -------------------------------------------------------------------------------- /docs/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/esonderegger/fecfile/0ac4f0372d4eddedd6bde850cd73c092a5ffc76b/docs/favicon-16x16.png -------------------------------------------------------------------------------- /docs/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/esonderegger/fecfile/0ac4f0372d4eddedd6bde850cd73c092a5ffc76b/docs/favicon-32x32.png -------------------------------------------------------------------------------- /docs/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/esonderegger/fecfile/0ac4f0372d4eddedd6bde850cd73c092a5ffc76b/docs/favicon.ico -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: fecfile: a python parser for the .fec file format 4 | --- 5 | 6 | # fecfile 7 | A python parser for the .fec file format ([github](https://github.com/esonderegger/fecfile)) ([PyPi](https://pypi.org/project/fecfile/)) 8 | 9 | This is a library for converting campaign finance filings stored in the .fec format into native python objects. It maps the comma/ASCII 28 delimited fields to canonical names based on the version the filing uses and then converts the values that are dates and numbers into the appropriate `int`, `float`, or `datetime` objects. 10 | 11 | This library is in relatively early testing. I've used it on a couple of projects, but I wouldn't trust it to work on all filings. That said, if you do try using it, I'd love to hear about it! 12 | 13 | ## Why? 14 | The FEC makes a ton of data available via the "export" links on the main site and the [developer API](https://api.open.fec.gov/developers/). For cases where those data sources are sufficient, they are almost certainly the easiest/best way to go. A few cases where one might need to be digging into raw filings are: 15 | 16 | - Getting information from individual itemizations including addresses. (The FEC doesn't include street addresses in bulk downloads.) 17 | - Getting data as soon as it has been filed, instead of waiting for it to be coded. (The FEC generally codes all filings received by 7pm eastern by 7am the next day. However, that means that a filing received at 11:59pm on Monday wouldn't be available until 7am on Wednesday, for example.) 18 | - Getting more data than the rate-limit on the developer API would allow. 19 | - Maintaining one's own database with all relevant campaign finance data, perhaps synced with another data source. 20 | 21 | Raw filings can be found by either downloading the [bulk data](https://www.fec.gov/data/advanced/?tab=bulk-data) zip files or from http requests like [this](https://docquery.fec.gov/dcdev/posted/1229017.fec). This library includes helper methods for both. 22 | 23 | ## Installation 24 | To get started, install from [pypi](https://pypi.org/project/fecfile/) by running the following command in your preferred terminal: 25 | 26 | ```shell 27 | pip install fecfile 28 | ``` 29 | 30 | ## Usage 31 | For the vast majority of filings, the easiest way to use this library will be to load filings all at once by using the `from_http(file_number)`, `from_file(file_path)`, or `loads(input)` methods. 32 | 33 | These methods will return a Python dictionary, with keys for `header`, `filing`, `itemizations`, and `text`. The `itemizations` dictionary contains lists of itemizations grouped by type (`Schedule A`, `Schedule B`, etc.). 34 | 35 | ### Examples: 36 | 37 | ```python 38 | import fecfile 39 | 40 | filing1 = fecfile.from_file('1229017.fec') 41 | print('${:,.2f}'.format(filing1['filing']['col_a_total_receipts'])) 42 | 43 | filing2 = fecfile.from_http(1146148) 44 | print(filing2['filing']['committee_name']) 45 | 46 | filing3 = fecfile.from_http(1146148) 47 | all_contributions = filing3['itemizations']['Schedule B'] 48 | mid_size_contributions = [item for item in all_contributions if 500 <= item[contribution_amount] < 1000] 49 | print(len(mid_size_contributions)) 50 | 51 | with open('1229017.fec') as file: 52 | parsed = fecfile.loads(file.read()) 53 | num_disbursements = len(parsed['itemizations']['Schedule B']) 54 | print(num_disbursements) 55 | 56 | url = 'https://docquery.fec.gov/dcdev/posted/1229017.fec' 57 | r = requests.get(url, headers={'User-Agent': 'Mozilla/5.0'}) 58 | parsed = fecfile.loads(r.text) 59 | fecfile.print_example(parsed) 60 | ``` 61 | 62 | Note: the docquery.fec.gov urls cause problems with the requests library when a user-agent is not supplied. There may be a cleaner fix to that though. 63 | 64 | ## Advanced Usage 65 | 66 | FEC filings can be arbitrarily large. Loading enormous filings into memory all at once can cause problems (including running out of memory). 67 | 68 | The `fecfile` library exposes the `iter_file` and `iter_http` methods to read large filings one line at a time. Both are generator functions that yield `FecItem` objects, which consist of `data` and `data_type` attributes. The data_type attribute can be one of "header", "summary", "itemization", "text", or "F99_text". The data attribute is a dictionary for all data types except for "F99_text", for which it is a string. 69 | 70 | ```python 71 | import fecfile 72 | import imaginary_database 73 | 74 | # Sometimes we only care about summary data, but want to be able to handle all filings, without 75 | # knowing anything about them before we attempt to parse. 76 | no_itemizations = {'filter_itemizations': []} 77 | for i in range(1300000, 1320000): 78 | for item in fecfile.iter_http(i, options=no_itemizations): 79 | if item.data_type == 'summary': 80 | imaginary_database.add_to_db(item.data) 81 | 82 | # Sometimes we only care about one type of itemization, but from a very large filing. 83 | # In this example, we add up all the contributions from Delaware in ActBlue's 2018 84 | # post-general filing 85 | only_contributions = {'filter_itemizations': ['SA']} 86 | de_total = 0 87 | for item in fecfile.iter_http(1300352, options=only_contributions): 88 | if item.data_type == 'itemization': 89 | if item.data['contributor_state'] == 'DE': 90 | de_total += item.data['contribution_amount'] 91 | print(de_total) 92 | 93 | # Sometimes we want to maintain a database where different types of itemizations live in their own 94 | # tables and have foreign key relationships to a summary record. 95 | file_path = '/path/to/99840.fec' 96 | filing = None 97 | for item in fecfile.iter_file(file_path): 98 | if item.data_type == 'summary': 99 | filing = imaginary_database.add_filing(file_number=99840, **item.data) 100 | if item.data_type == 'itemization': 101 | if item.data['form_type'].startswith('SA'): 102 | imaginary_database.add_contribution(filing=filing, **item.data) 103 | if item.data['form_type'].startswith('SB'): 104 | imaginary_database.add_disbursement(filing=filing, **item.data) 105 | if item.data['form_type'].startswith('SC'): 106 | imaginary_database.add_loan(filing=filing, **item.data) 107 | ``` 108 | 109 | You can also choose to use the `parse_header` and `parse_line` methods if you are implementing a different method of 110 | iterating over a filing's content. Before version 0.6, the below example was the only way to use `fecfile` to parse 111 | filings without loading the entire filing into memory. This approach should no longer be necessary, but is kept to 112 | show how example usage for those methods. 113 | 114 | ```python 115 | import fecfile 116 | 117 | version = None 118 | 119 | with open('1263179.fec') as file: 120 | for line in file: 121 | if version is None: 122 | header, version = fecfile.parse_header(line) 123 | else: 124 | parsed = fecfile.parse_line(line, version) 125 | save_to_db(parsed) 126 | ``` 127 | 128 | 129 | ## API Reference 130 | 131 |

loads

132 | 133 | ```python 134 | loads(input, options={}) 135 | ``` 136 | Deserialize ``input`` (a ``str`` instance 137 | containing an FEC document) to a Python object. 138 | 139 | Optionally, pass an array of strings to ``options['filter_itemizations']``. 140 | If included, ``loads`` will only parse lines that start with any of the 141 | strings in that array. For example, passing 142 | ``{'filter_itemizations': ['SC', 'SD']}`` to ``options``, will only include 143 | Schedule C and Schedule D itemizations. Also, passing 144 | ``{'filter_itemizations': []}`` to ``options`` will result in only the header 145 | and the filing being parsed and returned. 146 | 147 | Including `{'as_strings': True}` in the `options` dictionary will not attempt to convert values that are normally numeric or datetimes to their native python types and will return dictionaries with all values as strings. 148 | 149 |

parse_header

150 | 151 | ```python 152 | parse_header(hdr) 153 | ``` 154 | Deserialize a ``str`` or a list of ``str`` instances containing 155 | header information for an FEC document. Returns an Python object, the 156 | version ``str`` used in the document, and the number of lines used 157 | by the header. 158 | 159 | The third return value from parse_header--the number of lines used by the header--is only 160 | useful for early versions of the FEC file format, typically predating 2001. Versions 1 and 2 of the FEC file format allowed headers to be a multiline string beginning and ending with ``/*``. 161 | 162 | Returning the number of lines in the header allows us to know where the non-header lines begin. 163 | 164 |

parse_line

165 | 166 | ```python 167 | parse_line(line, version, line_num=None) 168 | ``` 169 | Deserialize a ``line`` (a ``str`` instance 170 | containing a line from an FEC document) to a Python object. 171 | 172 | ``version`` is a ``str`` instance for the version of the FEC file format 173 | to be used, and is required. 174 | 175 | ``line_num`` is optional and is used for debugging. If an error or 176 | warning is encountered, whatever is passed in to ``line_num`` will be 177 | included in the error/warning message. Normally the line number of the input file will be passed in, so that the user is shown the error and the line number in the original file that triggered the error. 178 | 179 |

from_http

180 | 181 | ```python 182 | from_http(file_number, options={}) 183 | ``` 184 | Utility method for retrieving a parsed Python representation of an FEC 185 | filing when it is not available as a local file. This method takes 186 | either a ``str`` or ``int`` as a ``file_number`` and requests the corresponding filing from 187 | the ``docquery.fec.gov`` server. It returns the parsed response. 188 | 189 | See [above](#fecfile.loads) for how documentation on how to use the optional 190 | ``options`` argument. 191 | 192 |

from_file

193 | 194 | ```python 195 | from_file(file_path, options={}) 196 | ``` 197 | Utility method for getting a parsed Python representation of an FEC 198 | filing that exists as a .fec file on a local machine. This method takes 199 | a ``str`` of the path to the file, and returns the parsed Python object. 200 | 201 | See [above](#fecfile.loads) for how documentation on how to use the optional 202 | ``options`` argument. 203 | 204 |

iter_http

205 | 206 | ```python 207 | iter_http(file_number, options={}) 208 | ``` 209 | Makes an http request for the given `file_number` and iterates over the response, yielding `FecItem` instances, which consist of `data` and `data_type` attributes. The `data_type` attribute can be one of "header", "summary", "itemization", "text", or "F99_text". The `data` attribute is a dictionary for all data types except for "F99_text", for which it is a string. This method avoids loading the entire filing into memory, as the `from_http` method does. 210 | 211 | See [above](#fecfile.loads) for how documentation on how to use the optional 212 | ``options`` argument. 213 | 214 |

iter_file

215 | 216 | ```python 217 | iter_file(file_path, options={}) 218 | ``` 219 | Opens a file at the given `file_path` and iterates over its contents, yielding `FecItem` instances, which consist of `data` and `data_type` attributes. The `data_type` attribute can be one of "header", "summary", "itemization", "text", or "F99_text". The `data` attribute is a dictionary for all data types except for "F99_text", for which it is a string. This method avoids loading the entire filing into memory, as the `from_file` method does. 220 | 221 | See [above](#fecfile.loads) for how documentation on how to use the optional 222 | ``options`` argument. 223 | 224 |

print_example

225 | 226 | ```python 227 | print_example(parsed) 228 | ``` 229 | Utility method for debugging - prints out a representative subset of 230 | the Python object returned by one of the deserialization methods. For 231 | filings with itemizations, it only prints the first of each type of 232 | itemization included in the object. 233 | 234 | 235 | ## Developing locally 236 | 237 | Assuming you already have Python3 and the ability to create virtual environments installed, first clone this repository from github and cd into it: 238 | 239 | ```shell 240 | git clone https://github.com/esonderegger/fecfile.git 241 | cd fecfile 242 | ``` 243 | 244 | Then create a virtual environment for this project (I use the following commands, but there are several ways to get the desired result): 245 | 246 | ```shell 247 | python3 -m venv env 248 | source env/bin/activate 249 | ``` 250 | 251 | Next, install the dependencies: 252 | 253 | ```shell 254 | python setup.py install 255 | ``` 256 | 257 | Finally, make some changes, and run: 258 | 259 | ```shell 260 | python tests.py 261 | ``` 262 | 263 | ## Thanks 264 | 265 | This project would be impossible without the work done by the kind folks at The New York Times [Newsdev team](https://github.com/newsdev). In particular, this project relies heavily on [fech](https://github.com/NYTimes/Fech). 266 | 267 | Many thanks to [Derek Willis](https://github.com/dwillis) for creating and maintaining [fech-sources](https://github.com/dwillis/fech-sources) which serves as the upstream source of truth for parsing libaries in various languages. 268 | 269 | A huge thank you to [Chris Zubak-Skees](https://github.com/chriszs), whose work on the [fec-parse](https://github.com/PublicI/fec-parse) javascript library inspired this project. 270 | 271 | Many thanks to [Jacob Fenton](https://github.com/jsfenfen) for writing the caching logic and for providing valuable feedback about the overall design of this library. 272 | 273 | ## Contributing 274 | 275 | I would love some help with this, particularly with the mapping from strings to `int`, `float`, and `datetime` types. Please [create an issue](https://github.com/esonderegger/fecfile/issues) or [make a pull request](https://github.com/esonderegger/fecfile/pulls). Or reach out privately via email - that works too. 276 | 277 | ## To do: 278 | 279 | Almost too much to list: 280 | 281 | - ~~Handle files from before v6 when they were comma-delimited~~ 282 | - create a `dumps` method for writing .fec files for round-trip tests 283 | - add more types to the types.json file 284 | - elegantly handle errors 285 | 286 | ## Changes 287 | 288 | See the [changelog](changelog.html) for a list of notable changes introduced in each version of fecfile. 289 | -------------------------------------------------------------------------------- /fecfile/__init__.py: -------------------------------------------------------------------------------- 1 | from . import fecparser, cache 2 | import requests 3 | 4 | 5 | FecParserMissingMappingError = cache.FecParserMissingMappingError 6 | 7 | 8 | class FilingUnavailableError(Exception): 9 | """when http requests for neither the electronic nor paper version 10 | of a filing return a 200 status code. Note: for now we don't 11 | differentiate between when a filing is unavailable because 12 | the request is returning a 500 error and when it doesn't exist and 13 | returns 404 errors for both paper and electronic urls""" 14 | def __init__(self, opts, msg=None): 15 | if msg is None: 16 | msg = ('The requested FEC file number ({}) is unavailable. Status code {}.'.format( 17 | opts['file_number'], 18 | opts['status_code'] 19 | )) 20 | super(FilingUnavailableError, self).__init__(msg) 21 | 22 | 23 | def loads(input, options={}): 24 | """Deserialize ``input`` (a ``str`` instance 25 | containing an FEC document) to a Python object. 26 | Optionally, pass an array of strings to options['filter_itemizations']. 27 | If included, loads will only parse lines that start with any of the 28 | strings in that array. For example, passing 29 | {'filter_itemizations': ['SC', 'SD']} to options, will only include 30 | Schedule C and Schedule D itemizations. Also, passing 31 | {'filter_itemizations': []} to options will result in only the header 32 | and the filing being parsed and returned. 33 | Including {'as_strings': True} in the options dictionary will not attempt 34 | to convert values that are normally numeric or datetimes to their native 35 | python types and will return dictionaries with all values as strings. 36 | """ 37 | return fecparser.loads(input, options) 38 | 39 | 40 | def parse_header(hdr): 41 | """Deserialize a ``str`` or a list of ``str`` instances containing 42 | header information for an FEC document. Returns an Python object, the 43 | version ``str`` used in the document, and the number of lines used 44 | by the header. 45 | 46 | The third return value of number of lines used by the header is only 47 | useful for versions 1 and 2 of the FEC file format, when the header 48 | was a multiline string beginning and ending with ``/*``. This allows 49 | us to pass in the entire contents of the file as a list of lines and 50 | know where to start parsing the non-header lines. 51 | """ 52 | if type(hdr) is list: 53 | return fecparser.parse_header(hdr) 54 | else: 55 | return fecparser.parse_header([hdr]) 56 | 57 | 58 | def parse_line(line, version, line_num=None): 59 | """Deserialize a ``line`` (a ``str`` instance 60 | containing a line from an FEC document) to a Python object. 61 | 62 | ``version`` is a ``str`` instance for the version of the FEC file format 63 | to be used, and is required. 64 | 65 | ``line_num`` is optional and is used for debugging. If an error or 66 | warning is encountered, whatever is passed in to ``line_num`` will be 67 | included in the error/warning message. 68 | """ 69 | return fecparser.parse_line(line, version, line_num) 70 | 71 | 72 | def from_http(file_number, options={}): 73 | """Utility method for getting a parsed Python representation of an FEC 74 | filing when you don't already have it on your computer. This method takes 75 | either a ``str`` or ``int`` as a ``file_number`` and requests it from 76 | the ``docquery.fec.gov`` server, then parses the response. 77 | """ 78 | url = 'https://docquery.fec.gov/dcdev/posted/{n}.fec'.format(n=file_number) 79 | req_headers = {'User-Agent': 'Mozilla/5.0'} 80 | r = requests.get(url, headers=req_headers, stream=True) 81 | if r.status_code == 404: 82 | url = 'https://docquery.fec.gov/paper/posted/{n}.fec'.format( 83 | n=file_number 84 | ) 85 | r = requests.get(url, headers=req_headers, stream=True) 86 | if r.status_code == 404: 87 | return None 88 | return fecparser.loads(r.iter_lines(), options=options) 89 | 90 | 91 | def from_file(file_path, options={}): 92 | """Utility method for getting a parsed Python representation of an FEC 93 | filing when you have the .fec file on your computer. This method takes 94 | a ``str`` of the path to the file, and returns the parsed Python object. 95 | """ 96 | try: 97 | with open(file_path, 'r') as file: 98 | unparsed = file.read() 99 | except UnicodeDecodeError: 100 | with open(file_path, 'r', encoding='ISO-8859-1') as file: 101 | unparsed = file.read() 102 | return fecparser.loads(unparsed, options=options) 103 | 104 | 105 | def print_example(parsed): 106 | """Utility method for debugging - prints out a representative subset of 107 | the Python object returned by one of the deserialization methods. For 108 | filings with itemizations, it only prints the first of each type of 109 | itemization included in the object. 110 | """ 111 | fecparser.print_example(parsed) 112 | 113 | 114 | def iter_http(file_number, options={}): 115 | """Makes an http request for the given file_number and iterates over 116 | the response, yielding FecItem instances, which consist of data and 117 | data_type attributes. The data_type attribute can be one of "header", 118 | "summary", "itemization", "text", or "F99_text". The data attribute is a 119 | dictionary for all data types except for "F99_text", for which it is a 120 | string. This method avoids loading the entire filing into memory, as the 121 | from_http method does. 122 | """ 123 | url = 'https://docquery.fec.gov/dcdev/posted/{n}.fec'.format(n=file_number) 124 | req_headers = {'User-Agent': 'Mozilla/5.0'} 125 | r = requests.get(url, headers=req_headers, stream=True) 126 | if r.status_code == 404: 127 | url = 'https://docquery.fec.gov/paper/posted/{n}.fec'.format( 128 | n=file_number 129 | ) 130 | r = requests.get(url, headers=req_headers, stream=True) 131 | if r.status_code == 200: 132 | for item in fecparser.iter_lines(r.iter_lines(), options=options): 133 | yield item 134 | else: 135 | raise FilingUnavailableError({'file_number': file_number, 'status_code': r.status_code}) 136 | 137 | 138 | def iter_file(file_path, options={}): 139 | """Opens a file at the given file_path and iterates over its 140 | contents, yielding FecItem instances, which consist of data and 141 | data_type attributes. The data_type attribute can be one of "header", 142 | "summary", "itemization", "text", or "F99_text". The data attribute is a 143 | dictionary for all data types except for "F99_text", for which it is a 144 | string. This method avoids loading the entire filing into memory, as the 145 | from_file method does. 146 | """ 147 | try: 148 | with open(file_path, 'r') as file: 149 | for item in fecparser.iter_lines(file, options=options): 150 | yield item 151 | except UnicodeDecodeError: 152 | with open(file_path, 'r', encoding='ISO-8859-1') as file: 153 | for item in fecparser.iter_lines(file, options=options): 154 | yield item 155 | -------------------------------------------------------------------------------- /fecfile/cache.py: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | 4 | MAPPING_CACHE_KEY = "%s:%s" 5 | MAPPING_CACHE = {} 6 | 7 | TYPE_CACHE_KEY = "%s:%s:%s" 8 | TYPE_CACHE = {} 9 | 10 | 11 | class FecParserMissingMappingError(Exception): 12 | """when a line in an FEC filing doesn't have a form/version mapping""" 13 | def __init__(self, opts, msg=None): 14 | if msg is None: 15 | msg = ('cannot parse version {v} of form {f} - ' 16 | 'no mapping found').format( 17 | v=opts['version'], 18 | f=opts['form'], 19 | ) 20 | super(FecParserMissingMappingError, self).__init__(msg) 21 | 22 | 23 | def getMapping_from_regex(mappings, form, version): 24 | """ Raises FecParserMissingMappingError if missing""" 25 | 26 | for mapping in mappings.keys(): 27 | if re.match(mapping, form, re.IGNORECASE): 28 | versions = mappings[mapping].keys() 29 | for v in versions: 30 | if re.match(v, version, re.IGNORECASE): 31 | return(mappings[mapping][v]) 32 | 33 | raise FecParserMissingMappingError({ 34 | 'form': form, 35 | 'version': version, 36 | }) 37 | 38 | 39 | def getMapping(mappings, form, version): 40 | """ Tries to find the mapping from cache before looking it up w regex """ 41 | key = MAPPING_CACHE_KEY % (form, version) 42 | try: 43 | mapping = MAPPING_CACHE[key] 44 | except KeyError: 45 | mapping = getMapping_from_regex(mappings, form, version) 46 | MAPPING_CACHE[key] = mapping 47 | return mapping 48 | 49 | 50 | def getTypeMapping_from_regex(types, form, version, field): 51 | """ Tries to find the mapping from cache before looking it up w regex """ 52 | for mapping in types.keys(): 53 | if re.match(mapping, form, re.IGNORECASE): 54 | versions = types[mapping].keys() 55 | for v in versions: 56 | if re.match(v, version, re.IGNORECASE): 57 | properties = types[mapping][v] 58 | prop_keys = properties.keys() 59 | for prop_key in prop_keys: 60 | if re.match(prop_key, field, re.IGNORECASE): 61 | prop = properties[prop_key] 62 | return prop 63 | return None 64 | 65 | 66 | def getTypeMapping(types, form, version, field): 67 | """ caches the mapping to dict """ 68 | key = TYPE_CACHE_KEY % (form, version, field) 69 | try: 70 | mapping = TYPE_CACHE[key] 71 | except KeyError: 72 | mapping = getTypeMapping_from_regex(types, form, version, field) 73 | TYPE_CACHE[key] = mapping 74 | return mapping 75 | -------------------------------------------------------------------------------- /fecfile/fecparser.py: -------------------------------------------------------------------------------- 1 | from datetime import datetime 2 | from pytz import timezone 3 | import csv 4 | import json 5 | import os 6 | import warnings 7 | 8 | from .cache import getTypeMapping, getMapping 9 | 10 | COLUMN_SEPARATOR = chr(0x1c) 11 | 12 | class FecParserTypeWarning(UserWarning): 13 | """when data in an FEC filing doesn't match types.json""" 14 | pass 15 | 16 | 17 | class FecItem: 18 | def __init__(self, data_type, data): 19 | self.data_type = data_type 20 | self.data = data 21 | 22 | 23 | this_file = os.path.abspath(__file__) 24 | this_dir = os.path.dirname(this_file) 25 | mappings_file = os.path.join(this_dir, 'mappings.json') 26 | types_file = os.path.join(this_dir, 'types.json') 27 | mappings = {} 28 | types = {} 29 | with open(mappings_file) as data_file: 30 | mappings = json.loads(data_file.read()) 31 | with open(types_file) as data_file: 32 | types = json.loads(data_file.read()) 33 | eastern = timezone('US/Eastern') 34 | 35 | 36 | comma_versions = ['1', '2', '3', '5'] 37 | 38 | 39 | def include_line(line, filter_list): 40 | for f in filter_list: 41 | if line.startswith(f) or line.startswith('"' + f): 42 | return True 43 | return False 44 | 45 | 46 | def loads(input, options={}): 47 | out = {'itemizations': {}, 'text': [], 'header': {}, 'filing': {}} 48 | iterable_input = input.split('\n') if type(input) is str else input 49 | for item in iter_lines(iterable_input, options=options): 50 | if item.data_type == 'header': 51 | out['header'] = item.data 52 | if item.data_type == 'summary': 53 | out['filing'] = item.data 54 | if item.data_type == 'F99_text': 55 | out['F99_text'] = item.data 56 | if item.data_type == 'text': 57 | out['text'].append(item.data) 58 | if item.data_type == 'itemization': 59 | form_type = item.data['form_type'] 60 | if form_type[0] == 'S': 61 | form_type = 'Schedule ' + item.data['form_type'][1] 62 | if form_type in out['itemizations']: 63 | out['itemizations'][form_type].append(item.data) 64 | else: 65 | out['itemizations'][form_type] = [item.data] 66 | return out 67 | 68 | 69 | def iter_lines(lines, options={}): 70 | version = None 71 | current_line_num = 0 72 | header_lines = [] 73 | text_section = False 74 | f99_text = '' 75 | summary = False 76 | for line_unk in lines: 77 | current_line_num += 1 78 | try: 79 | line = line_unk if type(line_unk) is str else line_unk.decode('utf-8') 80 | except UnicodeDecodeError: 81 | line = line_unk.decode('ISO-8859-1') 82 | if version is None: 83 | header_lines.append(line) 84 | header, version, header_length = parse_header(header_lines) 85 | if header is not None: 86 | yield FecItem('header', header) 87 | else: 88 | if summary and 'filter_itemizations' in options: 89 | if not include_line(line, options['filter_itemizations']): 90 | continue 91 | stripped = line.strip().upper() 92 | if stripped == '[BEGINTEXT]' or stripped == '[BEGIN TEXT]': 93 | text_section = True 94 | continue 95 | if stripped == '[ENDTEXT]' or stripped == '[END TEXT]': 96 | text_section = False 97 | yield FecItem('F99_text', f99_text) 98 | continue 99 | if text_section: 100 | if f99_text == '': 101 | f99_text = line 102 | else: 103 | f99_text += '\n' + line 104 | continue 105 | as_strings = options.get('as_strings', False) 106 | parsed = parse_line(line, version, current_line_num, as_strings) 107 | if parsed is None: 108 | continue 109 | if summary: 110 | if 'form_type' in parsed: 111 | yield FecItem('itemization', parsed) 112 | else: 113 | yield FecItem('text', parsed) 114 | else: 115 | summary = True 116 | yield FecItem('summary', parsed) 117 | 118 | 119 | def fields_from_line(line, use_ascii_28=False): 120 | if (COLUMN_SEPARATOR in line) or use_ascii_28: 121 | fields = line.split(COLUMN_SEPARATOR) 122 | else: 123 | reader = csv.reader([line]) 124 | fields = next(reader) 125 | for field in fields: 126 | if field.startswith('"') and field.endswith('"'): 127 | field = field[1:-1] 128 | return list(map( 129 | lambda x: x[1:-1] if (x.startswith('"') and x.endswith('"')) else x, 130 | fields 131 | )) 132 | 133 | 134 | def parse_header(lines): 135 | if lines[0].startswith('/*'): 136 | header_size = 1 137 | header = {'schedule_counts': {}} 138 | schedule_counts = False 139 | if header_size >= len(lines): 140 | return None, None, None 141 | while not lines[header_size].startswith('/*'): 142 | this_line = lines[header_size] 143 | if this_line.lower().startswith('schedule_counts'): 144 | schedule_counts = True 145 | else: 146 | header_fields = this_line.split('=') 147 | k = header_fields[0].strip().lower() 148 | v = header_fields[1].strip().lower() 149 | if schedule_counts: 150 | header['schedule_counts'][k] = int(v) 151 | else: 152 | header[k] = v 153 | header_size += 1 154 | if header_size >= len(lines): 155 | return None, None, None 156 | return header, header['fec_ver_#'], header_size + 1 157 | fields = fields_from_line(lines[0]) 158 | if fields[1] == 'FEC': 159 | parsed = parse_line(lines[0], fields[2], 0) 160 | return parsed, fields[2], 1 161 | parsed = parse_line(lines[0], fields[1], 0) 162 | return parsed, fields[1], 1 163 | 164 | 165 | def parse_line(line, version, line_num=None, as_strings=False): 166 | ascii_separator = True 167 | if version is None or version[0] in comma_versions: 168 | ascii_separator = False 169 | fields = fields_from_line(line, use_ascii_28=ascii_separator) 170 | if len(fields) < 2: 171 | return None 172 | form = fields[0].strip() 173 | this_version_mapping = getMapping(mappings, form, version) 174 | out = {} 175 | for i in range(len(this_version_mapping)): 176 | val = fields[i] if i < len(fields) else '' 177 | k = this_version_mapping[i] 178 | if as_strings: 179 | out[k] = val 180 | else: 181 | out[k] = getTyped(form, version, k, val, line_num) 182 | return out 183 | 184 | 185 | nones = ['none', 'n/a'] 186 | 187 | 188 | def getTyped(form, version, field, value, line_num): 189 | prop = getTypeMapping(types, form, version, field) 190 | if prop: 191 | try: 192 | if prop['type'] == 'integer': 193 | return int(value) 194 | if prop['type'] == 'float': 195 | stripped = value.strip() 196 | if stripped == '' or stripped.lower() in nones: 197 | return None 198 | sanitized = stripped.replace('%', '') 199 | return float(sanitized) 200 | if prop['type'] == 'date': 201 | format = prop['format'] 202 | stripped = value.strip() 203 | if stripped == '': 204 | return None 205 | parsed_date = datetime.strptime( 206 | stripped, 207 | format) 208 | return eastern.localize(parsed_date) 209 | except ValueError: 210 | warnings.warn( 211 | 'cannot parse value: {v}, as type: {t}, ' 212 | 'for field: {f}, in form: {o}, ' 213 | 'version: {r} (line {n})'.format( 214 | v=value, 215 | t=prop['type'], 216 | f=field, 217 | o=form, 218 | r=version, 219 | n='unknown' if line_num is None else line_num + 1, 220 | ), 221 | FecParserTypeWarning, 222 | ) 223 | return None 224 | return value 225 | 226 | 227 | def print_example(parsed): 228 | out = {'filing': parsed['filing'], 'itemizations': {}} 229 | for k in parsed['itemizations'].keys(): 230 | out['itemizations'][k] = parsed['itemizations'][k][0] 231 | print(json.dumps(out, sort_keys=True, indent=2, default=str)) 232 | -------------------------------------------------------------------------------- /fecfile/types.json: -------------------------------------------------------------------------------- 1 | { 2 | "^f1[an]": { 3 | ".*": { 4 | "^date_signed": { 5 | "type": "date", 6 | "format": "%Y%m%d" 7 | }, 8 | "^effective_date": { 9 | "type": "date", 10 | "format": "%Y%m%d" 11 | } 12 | } 13 | }, 14 | "^(f1m$|f1m[a|n])": { 15 | ".*": { 16 | ".*_date$": { 17 | "type": "date", 18 | "format": "%Y%m%d" 19 | }, 20 | "^date_signed": { 21 | "type": "date", 22 | "format": "%Y%m%d" 23 | } 24 | } 25 | }, 26 | "^f13[an]": { 27 | ".*": { 28 | ".*_date$": { 29 | "type": "date", 30 | "format": "%Y%m%d" 31 | }, 32 | "^date_signed": { 33 | "type": "date", 34 | "format": "%Y%m%d" 35 | } 36 | } 37 | }, 38 | "(^f132)|(^f133)": { 39 | ".*": { 40 | ".*_date$": { 41 | "type": "date", 42 | "format": "%Y%m%d" 43 | }, 44 | ".*_amount$": { 45 | "type": "float" 46 | } 47 | } 48 | }, 49 | "(^f2$)|(^f2[^4])": { 50 | ".*": { 51 | "^date_signed": { 52 | "type": "date", 53 | "format": "%Y%m%d" 54 | } 55 | } 56 | }, 57 | "(^f24$)|(^f24[an])": { 58 | ".*": { 59 | "^date_signed": { 60 | "type": "date", 61 | "format": "%Y%m%d" 62 | } 63 | } 64 | }, 65 | "^(f3[ant]|f3p$|(f3p[^s|3])|f3x$|f3x[ant]|f3z)": { 66 | ".*": { 67 | "^col_": { 68 | "type": "float" 69 | }, 70 | "^coverage_from_date": { 71 | "type": "date", 72 | "format": "%Y%m%d" 73 | }, 74 | "^coverage_through_date": { 75 | "type": "date", 76 | "format": "%Y%m%d" 77 | }, 78 | "^date_signed": { 79 | "type": "date", 80 | "format": "%Y%m%d" 81 | }, 82 | "^election_date": { 83 | "type": "date", 84 | "format": "%Y%m%d" 85 | } 86 | } 87 | }, 88 | "^f3s": { 89 | ".*": { 90 | "^date_general_election": { 91 | "type": "date", 92 | "format": "%Y%m%d" 93 | }, 94 | "^date_day_after_general_election": { 95 | "type": "date", 96 | "format": "%Y%m%d" 97 | }, 98 | "^[abcde]_": { 99 | "type": "float" 100 | }, 101 | "^(transfers|offsets|other|total)": { 102 | "type": "float" 103 | } 104 | } 105 | }, 106 | "^f4.*": { 107 | ".*": { 108 | "^col_": { 109 | "type": "float" 110 | }, 111 | "^coverage_from_date": { 112 | "type": "date", 113 | "format": "%Y%m%d" 114 | }, 115 | "^coverage_through_date": { 116 | "type": "date", 117 | "format": "%Y%m%d" 118 | }, 119 | "^date_signed": { 120 | "type": "date", 121 | "format": "%Y%m%d" 122 | } 123 | } 124 | }, 125 | "^f5[na]": { 126 | ".*": { 127 | "^coverage_from_date": { 128 | "type": "date", 129 | "format": "%Y%m%d" 130 | }, 131 | "^coverage_through_date": { 132 | "type": "date", 133 | "format": "%Y%m%d" 134 | }, 135 | "^date_signed": { 136 | "type": "date", 137 | "format": "%Y%m%d" 138 | }, 139 | "^total_contribution": { 140 | "type": "float" 141 | }, 142 | "^total_independent_expenditure": { 143 | "type": "float" 144 | } 145 | } 146 | }, 147 | "^f57": { 148 | ".*": { 149 | "^calendar_y_t_d_per_election_office": { 150 | "type": "float" 151 | }, 152 | "^dissemination_date": { 153 | "type": "date", 154 | "format": "%Y%m%d" 155 | }, 156 | "^expenditure_amount": { 157 | "type": "float" 158 | } 159 | } 160 | }, 161 | "(^f6$)|(^f6[an])": { 162 | ".*": { 163 | "^date_signed": { 164 | "type": "date", 165 | "format": "%Y%m%d" 166 | } 167 | } 168 | }, 169 | "^f65": { 170 | ".*": { 171 | "^contribution_amount": { 172 | "type": "float" 173 | }, 174 | "^contribution_date": { 175 | "type": "date", 176 | "format": "%Y%m%d" 177 | } 178 | } 179 | }, 180 | "(^f8$)|(^f8[an])": { 181 | ".*": { 182 | "^cash_on_hand$": { 183 | "type": "float" 184 | }, 185 | "^cash_on_hand_as_of_date": { 186 | "type": "date", 187 | "format": "%Y%m%d" 188 | }, 189 | "^total_assets": { 190 | "type": "float" 191 | }, 192 | "^receipts_ytd": { 193 | "type": "float" 194 | }, 195 | "^disbursements_ytd": { 196 | "type": "float" 197 | }, 198 | "^total_debts_owed": { 199 | "type": "float" 200 | }, 201 | "^total_num_creditors_owed": { 202 | "type": "float" 203 | }, 204 | "^num_creditors_part_ii": { 205 | "type": "float" 206 | }, 207 | "^total_debts_owed_part_ii": { 208 | "type": "float" 209 | }, 210 | "^total_to_be_paid_to_creditors": { 211 | "type": "float" 212 | }, 213 | "^date_signed": { 214 | "type": "date", 215 | "format": "%Y%m%d" 216 | } 217 | } 218 | }, 219 | "^f8ii$": { 220 | ".*": { 221 | "^date_incurred": { 222 | "type": "date", 223 | "format": "%Y%m%d" 224 | }, 225 | "^amount_owed_to": { 226 | "type": "float" 227 | }, 228 | "^amount_offered_in": { 229 | "type": "float" 230 | }, 231 | "^date_signed": { 232 | "type": "date", 233 | "format": "%Y%m%d" 234 | } 235 | } 236 | }, 237 | "^f8iii$": { 238 | ".*": { 239 | "^date_incurred": { 240 | "type": "date", 241 | "format": "%Y%m%d" 242 | }, 243 | "^amount_owed_to": { 244 | "type": "float" 245 | }, 246 | "^amount_expected_to_pay": { 247 | "type": "float" 248 | } 249 | } 250 | }, 251 | "(^f9$)|(^f9[an])": { 252 | ".*": { 253 | "^original_amendment_date": { 254 | "type": "date", 255 | "format": "%Y%m%d" 256 | }, 257 | "^coverage_from_date": { 258 | "type": "date", 259 | "format": "%Y%m%d" 260 | }, 261 | "^coverage_through_date": { 262 | "type": "date", 263 | "format": "%Y%m%d" 264 | }, 265 | "^date_public_distribution": { 266 | "type": "date", 267 | "format": "%Y%m%d" 268 | }, 269 | "^total_donations": { 270 | "type": "float" 271 | }, 272 | "^total_disbursements": { 273 | "type": "float" 274 | }, 275 | "^date_signed": { 276 | "type": "date", 277 | "format": "%Y%m%d" 278 | } 279 | } 280 | }, 281 | "^f92": { 282 | ".*": { 283 | "^contribution_date": { 284 | "type": "date", 285 | "format": "%Y%m%d" 286 | }, 287 | "^contribution_amount": { 288 | "type": "float" 289 | } 290 | } 291 | }, 292 | "^f93": { 293 | ".*": { 294 | "^expenditure_date": { 295 | "type": "date", 296 | "format": "%Y%m%d" 297 | }, 298 | "^expenditure_amount": { 299 | "type": "float" 300 | }, 301 | "^communication_date": { 302 | "type": "date", 303 | "format": "%Y%m%d" 304 | } 305 | } 306 | }, 307 | "^f99": { 308 | ".*": { 309 | "^date_signed": { 310 | "type": "date", 311 | "format": "%Y%m%d" 312 | } 313 | } 314 | }, 315 | "^f10$": { 316 | ".*": { 317 | "^expenditure_total_": { 318 | "type": "float" 319 | }, 320 | "^previous_expenditure_aggregate": { 321 | "type": "float" 322 | }, 323 | "^date_signed": { 324 | "type": "date", 325 | "format": "%Y%m%d" 326 | } 327 | } 328 | }, 329 | "^f105$": { 330 | ".*": { 331 | "^expenditure_amount": { 332 | "type": "float" 333 | }, 334 | "^expenditure_date": { 335 | "type": "date", 336 | "format": "%Y%m%d" 337 | } 338 | } 339 | }, 340 | "^sa": { 341 | ".*": { 342 | "^contribution_aggregate": { 343 | "type": "float" 344 | }, 345 | "^contribution_amount": { 346 | "type": "float" 347 | }, 348 | "^contribution_date": { 349 | "type": "date", 350 | "format": "%Y%m%d" 351 | } 352 | } 353 | }, 354 | "^sb": { 355 | ".*": { 356 | "^expenditure_amount": { 357 | "type": "float" 358 | }, 359 | "^semi_annual_refunded_bundled_amt": { 360 | "type": "float" 361 | }, 362 | "^expenditure_date": { 363 | "type": "date", 364 | "format": "%Y%m%d" 365 | } 366 | } 367 | }, 368 | "^sc": { 369 | ".*": { 370 | "^authorized_date": { 371 | "type": "date", 372 | "format": "%Y%m%d" 373 | }, 374 | "^date_signed": { 375 | "type": "date", 376 | "format": "%Y%m%d" 377 | }, 378 | "^deposit_acct_auth_date_presidential": { 379 | "type": "date", 380 | "format": "%Y%m%d" 381 | }, 382 | "^established_date": { 383 | "type": "date", 384 | "format": "%Y%m%d" 385 | }, 386 | "^loan_amount_original": { 387 | "type": "float" 388 | }, 389 | "^loan_balance": { 390 | "type": "float" 391 | }, 392 | "^loan_incurred_date": { 393 | "type": "date", 394 | "format": "%Y%m%d" 395 | }, 396 | "^loan_payment_to_date": { 397 | "type": "float" 398 | } 399 | } 400 | }, 401 | "^sd": { 402 | ".*": { 403 | "^balance_at_close_this_period": { 404 | "type": "float" 405 | }, 406 | "^beginning_balance_this_period": { 407 | "type": "float" 408 | }, 409 | "^incurred_amount_this_period": { 410 | "type": "float" 411 | }, 412 | "^payment_amount_this_period": { 413 | "type": "float" 414 | } 415 | } 416 | }, 417 | "^se": { 418 | ".*": { 419 | "^calendar_y_t_d_per_election_office": { 420 | "type": "float" 421 | }, 422 | "^date_signed": { 423 | "type": "date", 424 | "format": "%Y%m%d" 425 | }, 426 | "^disbursement_date": { 427 | "type": "date", 428 | "format": "%Y%m%d" 429 | }, 430 | "^dissemination_date": { 431 | "type": "date", 432 | "format": "%Y%m%d" 433 | }, 434 | "^expenditure_amount": { 435 | "type": "float" 436 | } 437 | } 438 | }, 439 | "^sf": { 440 | ".*": { 441 | "^expenditure_date": { 442 | "type": "date", 443 | "format": "%Y%m%d" 444 | }, 445 | "^expenditure_amount": { 446 | "type": "float" 447 | }, 448 | "^aggregate_general_elec_expended": { 449 | "type": "float" 450 | } 451 | } 452 | }, 453 | "^si": { 454 | ".*": { 455 | "^col_": { 456 | "type": "float" 457 | }, 458 | "^coverage_from_date": { 459 | "type": "date", 460 | "format": "%Y%m%d" 461 | }, 462 | "^coverage_through_date": { 463 | "type": "date", 464 | "format": "%Y%m%d" 465 | } 466 | } 467 | }, 468 | "^sl": { 469 | ".*": { 470 | "^col_": { 471 | "type": "float" 472 | }, 473 | "^coverage_from_date": { 474 | "type": "date", 475 | "format": "%Y%m%d" 476 | }, 477 | "^coverage_through_date": { 478 | "type": "date", 479 | "format": "%Y%m%d" 480 | } 481 | } 482 | } 483 | } 484 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup, find_packages 2 | 3 | 4 | with open('README.md', 'r') as file: 5 | long_description = '\n'.join(file.readlines()[3:]) 6 | 7 | 8 | requirements = [ 9 | 'pytz>=2018.4', 10 | 'requests>=2.19.1', 11 | ] 12 | 13 | 14 | setup( 15 | name='fecfile', 16 | version='0.9.1', 17 | description='a python parser for the .fec file format', 18 | long_description=long_description, 19 | long_description_content_type="text/markdown", 20 | url='https://esonderegger.github.io/fecfile/', 21 | project_urls={ 22 | 'Bug Tracker': 'https://github.com/esonderegger/fecfile/issues', 23 | 'Source Code': 'https://github.com/esonderegger/fecfile/', 24 | }, 25 | author='Evan Sonderegger', 26 | author_email='evan@rpy.xyz', 27 | license='Apache License 2.0', 28 | keywords='fec campaign finance politics', 29 | classifiers=[ 30 | 'Development Status :: 3 - Alpha', 31 | 'Environment :: Console', 32 | 'Intended Audience :: Developers', 33 | 'License :: OSI Approved :: Apache Software License', 34 | 'Operating System :: OS Independent', 35 | 'Programming Language :: Python', 36 | ], 37 | packages=find_packages(exclude=['docs', 'test-data']), 38 | package_data={'fecfile': ['mappings.json', 'types.json']}, 39 | install_requires=requirements, 40 | zip_safe=False, 41 | ) 42 | -------------------------------------------------------------------------------- /speedtests.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | from datetime import datetime 3 | import fecfile 4 | 5 | from collections import Counter 6 | 7 | 8 | def speed_test(filepath): 9 | print("+++++\nRunning speed test on %s" % filepath) 10 | formtypecount = Counter() 11 | 12 | start = datetime.now() 13 | parsed = {} 14 | with open(filepath) as file: 15 | linecount = 0 16 | version = None 17 | for line in file: 18 | linecount += 1 19 | if version is None: 20 | results = fecfile.parse_header(line) 21 | version = results[1] 22 | else: 23 | parsed = fecfile.parse_line(line, version) 24 | if not parsed: 25 | print("** not parsed %s" % line) 26 | else: 27 | # count the form type, if given 28 | try: 29 | formtypecount.update({parsed['form_type'].upper(): 1}) 30 | except KeyError: 31 | continue 32 | 33 | end = datetime.now() 34 | print("+++++\nResults:") 35 | print("\tRan %s rows in %s" % (sum(formtypecount.values()), end-start)) 36 | print("\tTotal rows processed = %s" % formtypecount) 37 | 38 | 39 | def from_file_speed(filepath, options={}): 40 | print('++++\nRunning speed test on {0} with {1}'.format(filepath, options)) 41 | start = datetime.now() 42 | parsed = fecfile.from_file(filepath, options) 43 | end = datetime.now() 44 | num_itemizations = 0 45 | for itemization_type in parsed['itemizations'].keys(): 46 | num_itemizations += len(parsed['itemizations'][itemization_type]) 47 | print('parsed file with {0} itemizations in {1}'.format( 48 | num_itemizations, 49 | end - start, 50 | )) 51 | 52 | 53 | class SpeedTestSmallFile(unittest.TestCase): 54 | def test_simple(self): 55 | speed_test('test-data/1229017.fec') 56 | 57 | def test_from_file(self): 58 | a_filter = {'filter_itemizations': ['SB']} 59 | from_file_speed('test-data/1229017.fec', options=a_filter) 60 | 61 | 62 | class SpeedTestSmallOldFile(unittest.TestCase): 63 | def test_simple(self): 64 | speed_test('test-data/27789.fec') 65 | 66 | def test_from_file(self): 67 | a_filter = {'filter_itemizations': ['SB']} 68 | from_file_speed('test-data/27789.fec', options=a_filter) 69 | 70 | 71 | class SpeedTestMediumRecentFile(unittest.TestCase): 72 | def test_simple(self): 73 | speed_test('test-data/1162172.fec') 74 | 75 | def test_from_file(self): 76 | a_filter = {'filter_itemizations': ['SD']} 77 | from_file_speed('test-data/1162172.fec', options=a_filter) 78 | 79 | 80 | if __name__ == '__main__': 81 | regular_tests = unittest.TestSuite([ 82 | SpeedTestSmallFile('test_simple'), 83 | SpeedTestSmallOldFile('test_simple'), 84 | SpeedTestMediumRecentFile('test_simple'), 85 | ]) 86 | from_file_tests = unittest.TestSuite([ 87 | SpeedTestSmallFile('test_from_file'), 88 | SpeedTestSmallOldFile('test_from_file'), 89 | SpeedTestMediumRecentFile('test_from_file'), 90 | ]) 91 | 92 | unittest.TextTestRunner().run(from_file_tests) 93 | -------------------------------------------------------------------------------- /test-data/1229017.fec: -------------------------------------------------------------------------------- 1 | HDRFEC8.2NGP5.00 2 | F3NC00215905DeFazio for CongressPO Box 1316SpringfieldOR97477OR0412PP201820180515OR2018040120180425GreenJefA2018050350913.5530.0050883.5528017.19220.0027797.191141844.620.000.009364.174395.9713760.140.0037153.410.0050913.550.000.000.000.00220.000.0051133.5528017.190.000.000.000.0030.000.000.0030.001000.0029047.191119758.2651133.551170891.8129047.191141844.62968140.572892.02965248.55472418.782264.89470153.89202954.74214649.95417604.690.00550535.880.00968140.570.000.000.000.002264.89393.59970799.05472418.780.000.000.000.001892.020.001000.002892.02112000.00587310.80 3 | SA11AIC00215905C11233423ORGCoquille Indian Tribe3050 Tremont StNorth BendOR974593059P2018201804251000.001000.00 4 | SA11AIC00215905C11233017INDMcAllisterBrianB A448 Seventh StBrooklynNY11215P2018201804181000.001000.00PresidentMcAllister Towing and Transportation C 5 | SA11AIC00215905C11233016INDMillerDonaldW1422 Penny LaneGreenfieldIN46140P2018201804181000.001000.00TPG Marine Enterprises, LLCPresident/Principal 6 | SA11AIC00215905C11233022INDParkerTimPO Box 20908TuscaloosaAL35402P2018201804181000.001000.00Parker Towing CompanyPresident 7 | SA11AIC00215905C11233406INDTimmIanL1505 NE 46th AvePortlandOR97213P201820180425500.00500.00noneretired 8 | SA11AIC00215905C11233415INDZornKathleenF4199 Melqua RoadRoseburgOR97471P201820180425100.00285.00Not EmployedNot Employed 9 | SA11AIC00215905C11232902AC11232902ABSA11AIINDAhlstedtAlice442 Monroe StreetEugeneOR97402P20182018041950.00400.00Not EmployedNot Employed* Earmarked Contribution: See Below  10 | SA11AIC00215905C11232902ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018042250.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 11 | SA11AIC00215905C11233473AC11233473ABSA11AIINDAllenTeresa3124 Garden Valley RdRoseburgOR97471P20182018042525.00300.00Not employedNot employed* Earmarked Contribution: See Below  12 | SA11AIC00215905C11233473ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018042525.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 13 | SA11AIC00215905C11232673AC11232673ABSA11AIINDAnzingerDawn25488 Wonderly LanePhilomathOR97370P20182018040225.00241.00Oregon State UniversityUniversity Instructor* Earmarked Contribution: See Below  14 | SA11AIC00215905C11232673ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018040825.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 15 | SA11AIC00215905C11232746AC11232746ABSA11AIINDAnzingerDawn25488 Wonderly LanePhilomathOR97370P2018201804067.00241.00Oregon State UniversityUniversity Instructor* Earmarked Contribution: See Below  16 | SA11AIC00215905C11232746ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P2018201804087.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 17 | SA11AIC00215905C11232763AC11232763ABSA11AIINDBakerJoyce4861 DonaldEugeneOR97405P20182018040725.00300.00selfCounselor* Earmarked Contribution: See Below  18 | SA11AIC00215905C11232763ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018040825.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 19 | SA11AIC00215905C11232692AC11232692ABSA11AIINDBrayerHerbertP.O. Box 38OphirOR97464P20182018040325.00450.00Not EmployedNot Employed* Earmarked Contribution: See Below  20 | SA11AIC00215905C11232692ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018040825.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 21 | SA11AIC00215905C11154944AC11154944ABSA11AIINDCardKevinL.4326 SE 73RD AVEPORTLANDOR97206P20182018040120.00375.00US POSTAL SERVICELETTER CARRIER* Earmarked Contribution: See Below  22 | SA11AIC00215905C11154944ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018040120.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 23 | SA11AIC00215905C11232736AC11232736ABSA11AIINDCatheyJenny632 City View BlvdSpringfieldOR97477P20182018040525.00388.00Springfield Public SchoolsTeacher* Earmarked Contribution: See Below  24 | SA11AIC00215905C11232736ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018040825.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 25 | SA11AIC00215905C11232910AC11232910ABSA11AIINDCegelnikNormanPO Box 682SelmaOR97538P20182018042015.00268.00nonenot employed* Earmarked Contribution: See Below  26 | SA11AIC00215905C11232910ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018042215.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 27 | SA11AIC00215905C11232724AC11232724ABSA11AIINDCennameCollette86254 Del Rio streeteugeneOR97405P20182018040515.00255.00Not employedNot employed* Earmarked Contribution: See Below  28 | SA11AIC00215905C11232724ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018040815.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 29 | SA11AIC00215905C11233469AC11233469ABSA11AIINDChancePatricia5606 SW Dolph CtPortlandOR97219P20182018042510.00240.00SelfClinical Social Workee* Earmarked Contribution: See Below  30 | SA11AIC00215905C11233469ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018042510.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 31 | SA11AIC00215905C11232845AC11232845ABSA11AIINDCherryJackie4949 SE 108th AvePortlandOR97266P20182018041125.00350.00David Douglas school districtTeacher* Earmarked Contribution: See Below  32 | SA11AIC00215905C11232845ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018041525.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 33 | SA11AIC00215905C11233472AC11233472ABSA11AIINDClarkBarb530 Edgemont WaySpringfieldOR97477P20182018042525.00300.00Not employedNot employed* Earmarked Contribution: See Below  34 | SA11AIC00215905C11233472ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018042525.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 35 | SA11AIC00215905C11232921AC11232921ABSA11AIINDColeLarry250 Horseshoe DrGrants PassOR97526P20182018042120.00307.00nonenone* Earmarked Contribution: See Below  36 | SA11AIC00215905C11232921ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018042220.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 37 | SA11AIC00215905C11232933AC11232933ABSA11AIINDCoronadoIan2634 Laurel Hill DrEugeneOR97403P20182018042215.00210.00Lane Community Collegeadministrator* Earmarked Contribution: See Below  38 | SA11AIC00215905C11232933ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018042215.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 39 | SA11AIC00215905C11232855AC11232855ABSA11AIINDDotsonLyle24585 Ervin RdPhilomathOR97370P20182018041325.00386.00State of OregonHomecare* Earmarked Contribution: See Below  40 | SA11AIC00215905C11232855ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018041525.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 41 | SA11AIC00215905C11232847AC11232847ABSA11AIINDDwyerThomas530 SE Tenino StPortlandOR97202P20182018041125.00575.00TDASImechanic* Earmarked Contribution: See Below  42 | SA11AIC00215905C11232847ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018041525.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 43 | SA11AIC00215905C11232897AC11232897ABSA11AIINDEnglishJudy815 NW JamescorvallisOR973309731P20182018041910.00257.00nonenot employed* Earmarked Contribution: See Below  44 | SA11AIC00215905C11232897ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018042210.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 45 | SA11AIC00215905C11232943AC11232943ABSA11AIINDFagnanJean10424SW Terwilliger PlacePortlandOR97219P201820180422100.00325.00Not employedNot employed* Earmarked Contribution: See Below  46 | SA11AIC00215905C11232943ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P201820180422100.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 47 | SA11AIC00215905C11233459AC11233459ABSA11AIINDFordDavidR62560 Crown Point RdCoos BayOR974207610P20182018042415.00520.00selfmusician* Earmarked Contribution: See Below  48 | SA11AIC00215905C11233459ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018042515.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 49 | SA11AIC00215905C11232866AC11232866ABSA11AIINDGehringSuzanne39817 Kingston Jordan RdScioOR973749314P20182018041625.00450.00Not employedODOT* Earmarked Contribution: See Below  50 | SA11AIC00215905C11232866ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018042225.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 51 | SA11AIC00215905C11232706AC11232706ABSA11AIINDGirtMaradee325 Park Ave.EugeneOR97404P20182018040415.00255.00Not employedNot employed* Earmarked Contribution: See Below  52 | SA11AIC00215905C11232706ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018040815.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 53 | SA11AIC00215905C11232735AC11232735ABSA11AIINDGoldCarol4937 SW Hollyhock CircleCorvallisOR973331773P20182018040525.00410.00nonenot employed* Earmarked Contribution: See Below  54 | SA11AIC00215905C11232735ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018040825.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 55 | SA11AIC00215905C11232717AC11232717ABSA11AIINDGreggDawn513 7th Ave SEAlbanyOR97321P20182018040420.00390.00Not EmployedNot Employed* Earmarked Contribution: See Below  56 | SA11AIC00215905C11232717ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018040820.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 57 | SA11AIC00215905C11232879AC11232879ABSA11AIINDGreggDawn513 7th Ave SEAlbanyOR97321P20182018041715.00390.00Not EmployedNot Employed* Earmarked Contribution: See Below  58 | SA11AIC00215905C11232879ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018042215.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 59 | SA11AIC00215905C11232785AC11232785ABSA11AIINDGuentherAllanya4405 SE Center StreetPortlandOR97206P20182018040815.00277.00Not employedNot employed* Earmarked Contribution: See Below  60 | SA11AIC00215905C11232785ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018040815.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 61 | SA11AIC00215905C11232812AC11232812ABSA11AIINDGuentherAllanya4405 SE Center StreetPortlandOR97206P20182018040910.00277.00Not employedNot employed* Earmarked Contribution: See Below  62 | SA11AIC00215905C11232812ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018041510.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 63 | SA11AIC00215905C11154964AC11154964ABSA11AIINDHannDavid2869 NW Margarita PlaceCorvallisOR973303461P201820180401100.00575.00Not EmployedNot Employed* Earmarked Contribution: See Below  64 | SA11AIC00215905C11154964ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P201820180401100.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 65 | SA11AIC00215905C11232786AC11232786ABSA11AIINDHarrisonChristine712 Oak StBrownsvilleOR97327P20182018040825.00358.00Not EmployedNot Employed* Earmarked Contribution: See Below  66 | SA11AIC00215905C11232786ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018040825.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 67 | SA11AIC00215905C11232783AC11232783ABSA11AIINDHartGrace25607 Fleck RoadVenetaOR97487P20182018040815.00311.00Not employedNot employed* Earmarked Contribution: See Below  68 | SA11AIC00215905C11232783ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018040815.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 69 | SA11AIC00215905C11232896AC11232896ABSA11AIINDHayesElle16055 SW Walker Rd #251BeavertonOR97006P20182018041950.00392.00Not employedNot employed* Earmarked Contribution: See Below  70 | SA11AIC00215905C11232896ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018042250.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 71 | SA11AIC00215905C11232929AC11232929ABSA11AIINDHenjumIreneI1211 M StreetSpringfieldOR97477P20182018042215.00270.00Back to the Rootslandscaper* Earmarked Contribution: See Below  72 | SA11AIC00215905C11232929ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018042215.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 73 | SA11AIC00215905C11232831AC11232831ABSA11AIINDHinsonBruce1741 Escalante StEugeneOR974042388P20182018041050.00707.00Lane County H&HSMental Health Specialist II* Earmarked Contribution: See Below  74 | SA11AIC00215905C11232831ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018041550.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 75 | SA11AIC00215905C11232728AC11232728ABSA11AIINDHollanderBev27850 Lady Slipper Loop RedfeatherEugeneOR97405P20182018040515.00235.00information requestedinformation requested* Earmarked Contribution: See Below  76 | SA11AIC00215905C11232728ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018040815.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 77 | SA11AIC00215905C11232832AC11232832ABSA11AIINDHoskinsJoanna2095 Fairmount BoulevardEugeneOR97403P20182018041035.00490.00Not employedNot employed* Earmarked Contribution: See Below  78 | SA11AIC00215905C11232832ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018041535.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 79 | SA11AIC00215905C11232905AC11232905ABSA11AIINDHowardNancyP. O. Box 1211MulinoOR97042P2018201804205.00535.00Not employedNot employed* Earmarked Contribution: See Below  80 | SA11AIC00215905C11232905ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P2018201804225.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 81 | SA11AIC00215905C11232906AC11232906ABSA11AIINDHowardNancyP. O. Box 1211MulinoOR97042P20182018042215.00535.00Not employedNot employed* Earmarked Contribution: See Below  82 | SA11AIC00215905C11232906ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018042215.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 83 | SA11AIC00215905C11232895AC11232895ABSA11AIINDInnocentiMarcello2457 Dalton DriveEugeneOR97404P201820180419100.001200.00ABTS Inc.Accountant* Earmarked Contribution: See Below  84 | SA11AIC00215905C11232895ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P201820180422100.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 85 | SA11AIC00215905C11232705AC11232705ABSA11AIINDIvinsChris924 Elizabeth St.EugeneOR97402P20182018040415.00255.00Not employedNot employed* Earmarked Contribution: See Below  86 | SA11AIC00215905C11232705ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018040815.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 87 | SA11AIC00215905C11232862AC11232862ABSA11AIINDJacksonKen1296 NW Garibaldi StHillsboroOR97124P20182018041425.00450.00nonenone* Earmarked Contribution: See Below  88 | SA11AIC00215905C11232862ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018041525.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 89 | SA11AIC00215905C11233453AC11233453ABSA11AIINDJacobson-TepferEsther31700 Owl Rd.EugeneOR974059547P20182018042315.00264.00University of Oregonretired* Earmarked Contribution: See Below  90 | SA11AIC00215905C11233453ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018042515.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 91 | SA11AIC00215905C11232934AC11232934ABSA11AIINDJohnstonJim951 South 37th PlaceSpringfieldOR97478P20182018042215.00210.00Retired U. of O.Retired Energy Manager* Earmarked Contribution: See Below  92 | SA11AIC00215905C11232934ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018042215.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 93 | SA11AIC00215905C11233461AC11233461ABSA11AIINDJonesDonald1926 nw 29th placeCorvallisOR973303948P20182018042425.00450.00Not employedNot employed* Earmarked Contribution: See Below  94 | SA11AIC00215905C11233461ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018042525.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 95 | SA11AIC00215905C11232716AC11232716ABSA11AIINDJonesKirk2281 Sherman AveNorth BendOR974593310P20182018040425.00300.00Not EmployedNot Employed* Earmarked Contribution: See Below  96 | SA11AIC00215905C11232716ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018040825.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 97 | SA11AIC00215905C11233452AC11233452ABSA11AIINDKartCarolyn1170 SE Alexander AvecorvallisOR97333P20182018042325.00485.00Greater Albany Public Schoolsteacher* Earmarked Contribution: See Below  98 | SA11AIC00215905C11233452ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018042525.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 99 | SA11AIC00215905C11232936AC11232936ABSA11AIINDKelleyMatthew611 NE 63rd AvePortlandOR972134333P20182018042225.00300.00Metropolitan ServicesSmall business administration* Earmarked Contribution: See Below  100 | SA11AIC00215905C11232936ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018042225.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 101 | SA11AIC00215905C11232744AC11232744ABSA11AIINDKelskyKaren2060 Alder St.EugeneOR97405P20182018040615.00210.00selfcareer coach* Earmarked Contribution: See Below  102 | SA11AIC00215905C11232744ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018040815.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 103 | SA11AIC00215905C11233474AC11233474ABSA11AIINDKlebanDaniel26 Cortland RoadFreeportME04032P201820180425250.00250.00Maine Beer CompanyOwner* Earmarked Contribution: See Below  104 | SA11AIC00215905C11233474ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P201820180425250.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 105 | SA11AIC00215905C11232859AC11232859ABSA11AIINDKonoRobert HH5450 SW Erickson Ave.Apt. B212BeavertonOR97005P20182018041415.00270.00not employednot employed* Earmarked Contribution: See Below  106 | SA11AIC00215905C11232859ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018041515.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 107 | SA11AIC00215905C11232730AC11232730ABSA11AIINDKyleSharon2405 NE 61st AvenuePortlandOR97213P20182018040515.00264.00not employednot employed* Earmarked Contribution: See Below  108 | SA11AIC00215905C11232730ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018040815.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 109 | SA11AIC00215905C11232915AC11232915ABSA11AIINDLodgeRandy4055 Royal ave spc 115EugeneOR97402P20182018042115.00240.00Not employedNot employed* Earmarked Contribution: See Below  110 | SA11AIC00215905C11232915ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018042215.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 111 | SA11AIC00215905C11232807AC11232807ABSA11AIINDMartinKim560 Se 10th StDundeeOR97115P20182018040924.00384.00Not EmployedNot Employed* Earmarked Contribution: See Below  112 | SA11AIC00215905C11232807ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018041524.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 113 | SA11AIC00215905C11232734AC11232734ABSA11AIINDMattison-NottageDianeK2315 W 21st AveEugeneOR974051395P20182018040525.00350.00Not EmployedNot Employed* Earmarked Contribution: See Below  114 | SA11AIC00215905C11232734ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018040825.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 115 | SA11AIC00215905C11232931AC11232931ABSA11AIINDMeigsSarah220 NW 30th StreetCorvallisOR97330P20182018042250.00700.00self-employedinvestor* Earmarked Contribution: See Below  116 | SA11AIC00215905C11232931ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018042250.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 117 | SA11AIC00215905C11232898AC11232898ABSA11AIINDMelendyBruce5422 Portland Rd #82SalemOR97305P20182018041915.00246.00not employednot employed* Earmarked Contribution: See Below  118 | SA11AIC00215905C11232898ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018042215.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 119 | SA11AIC00215905C11232759AC11232759ABSA11AIINDMooreMargaret21280 Hurita PlaceBendOR97702P20182018040710.00537.00The StandardVCM* Earmarked Contribution: See Below  120 | SA11AIC00215905C11232759ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018040810.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 121 | SA11AIC00215905C11232928AC11232928ABSA11AIINDMooreMargaret21280 Hurita PlaceBendOR97702P2018201804225.00537.00The StandardVCM* Earmarked Contribution: See Below  122 | SA11AIC00215905C11232928ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P2018201804225.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 123 | SA11AIC00215905C11232890AC11232890ABSA11AIINDMyersGeorgeE20 SE 103rd #339PortlandOR972162870P20182018041815.00285.00Not employedNot employed* Earmarked Contribution: See Below  124 | SA11AIC00215905C11232890ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018042215.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 125 | SA11AIC00215905C11232813AC11232813ABSA11AIINDMyersJillyn15826 So. Holcomb BlvdOregon CityOR97045P20182018040915.00228.00Mt Hood Women's HealthMedical Field* Earmarked Contribution: See Below  126 | SA11AIC00215905C11232813ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018041515.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 127 | SA11AIC00215905C11232852AC11232852ABSA11AIINDNelsonReneeL2375 wilson driveeugeneOR974051419P20182018041150.00840.00Eugene Parks and Recartist* Earmarked Contribution: See Below  128 | SA11AIC00215905C11232852ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018041550.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 129 | SA11AIC00215905C11232685AC11232685ABSA11AIINDNewtonNaomi1337 6th st 12SPRINGFIELDOR97477P2018201804034.17230.04Not EmployedNot Employed* Earmarked Contribution: See Below  130 | SA11AIC00215905C11232685ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P2018201804084.178460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 131 | SA11AIC00215905C11232778AC11232778ABSA11AIINDNewtonNaomi1337 6th st 12SPRINGFIELDOR97477P20182018040815.00230.04Not EmployedNot Employed* Earmarked Contribution: See Below  132 | SA11AIC00215905C11232778ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018040815.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 133 | SA11AIC00215905C11232894AC11232894ABSA11AIINDOBrienRichardJ2540 Pierce StreetEugeneOR974051606P20182018041950.00608.33NoneNot employed* Earmarked Contribution: See Below  134 | SA11AIC00215905C11232894ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018042250.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 135 | SA11AIC00215905C11232901AC11232901ABSA11AIINDPlankBeverly AA1428 SW Trophy Pl.CorvallisOR97333P20182018041925.00377.50nonenone* Earmarked Contribution: See Below  136 | SA11AIC00215905C11232901ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018042225.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 137 | SA11AIC00215905C11232821AC11232821ABSA11AIINDReaganMargaret97305 Signal ButteGold BeachOR97444P201820180409100.00265.00Not EmployedNot Employed* Earmarked Contribution: See Below  138 | SA11AIC00215905C11232821ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P201820180415100.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 139 | SA11AIC00215905C11233463AC11233463ABSA11AIINDRiggsJudithM2904 NW Angelica DriveCorvallisOR97330P20182018042425.00300.00Not EmployedNot Employed* Earmarked Contribution: See Below  140 | SA11AIC00215905C11233463ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018042525.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 141 | SA11AIC00215905C11232857AC11232857ABSA11AIINDSauseDale155 East Market AvenueCoos BayOR97420P2018201804132500.002500.00Sause Bros.Inc.President* Earmarked Contribution: See Below  142 | SA11AIC00215905C11232857ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P2018201804152500.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 143 | SA11AIC00215905C11232755AC11232755ABSA11AIINDSavilleJames R2055 Chambers StreetEugeneOR97405P20182018040650.00461.00Not employedNot employed* Earmarked Contribution: See Below  144 | SA11AIC00215905C11232755ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018040850.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 145 | SA11AIC00215905C11232886AC11232886ABSA11AIINDSavilleJames R2055 Chambers StreetEugeneOR97405P20182018041715.00461.00Not employedNot employed* Earmarked Contribution: See Below  146 | SA11AIC00215905C11232886ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018042215.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 147 | SA11AIC00215905C11232939AC11232939ABSA11AIINDScottCandisPO Box 414Scotts MillsOR97375P20182018042224.00266.00Highland LaboratoriesCEO* Earmarked Contribution: See Below  148 | SA11AIC00215905C11232939ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018042224.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 149 | SA11AIC00215905C11233468AC11233468ABSA11AIINDShelleyKathleen46525 McKenzie HwyvifaOR97488P20182018042525.00425.00noneretired* Earmarked Contribution: See Below  150 | SA11AIC00215905C11233468ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018042525.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 151 | SA11AIC00215905C11232871AC11232871ABSA11AIINDSimondsPaul E.23515 Highway 36CheshireOR97419P20182018041750.00350.00RetiredAnthropologist* Earmarked Contribution: See Below  152 | SA11AIC00215905C11232871ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018042250.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 153 | SA11AIC00215905C11232815AC11232815ABSA11AIINDSingerJames432 Lakefair Circle NorthKeizerOR973033592P20182018040915.00240.00retirednot employed* Earmarked Contribution: See Below  154 | SA11AIC00215905C11232815ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018041515.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 155 | SA11AIC00215905C11233451AC11233451ABSA11AIINDSpoonerAlicia05921 N Mercer Lake RoadFlorenceOR97439P20182018042315.00208.00Spooner Industries IncPublisher* Earmarked Contribution: See Below  156 | SA11AIC00215905C11233451ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018042515.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 157 | SA11AIC00215905C11232799AC11232799ABSA11AIINDSwansonCharlie2010 Fairmount Blvd.EugeneOR97403P20182018040925.00375.00Not employedNot employed* Earmarked Contribution: See Below  158 | SA11AIC00215905C11232799ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018041525.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 159 | SA11AIC00215905C11233450AC11233450ABSA11AIINDWenzlElizabeth2137 Alder St.EugeneOR974052941P20182018042315.00217.00Not employedNot employed* Earmarked Contribution: See Below  160 | SA11AIC00215905C11233450ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018042515.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 161 | SA11AIC00215905C11232916AC11232916ABSA11AIINDWickhamCheryl93344 Hubbard Creek Rd. P.O. Box 4Port OrfordOR97465P20182018042115.00286.00Not employedNot employed* Earmarked Contribution: See Below  162 | SA11AIC00215905C11232916ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018042215.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 163 | SA11AIC00215905C11232833AC11232833ABSA11AIINDWolfenbargerLynda635 NW 34th StreetCorvallisOR973305049P20182018041015.00210.00Not employedNot employed* Earmarked Contribution: See Below  164 | SA11AIC00215905C11232833ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018041515.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 165 | SA11AIC00215905C11232932AC11232932ABSA11AIINDWoodJudith180 Shobu LaneRoseburgOR974718990P20182018042215.00210.00not employednot employed* Earmarked Contribution: See Below  166 | SA11AIC00215905C11232932ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018042215.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 167 | SA11AIC00215905C11232795AC11232795ABSA11AIINDZouselHeather3545 yew aveCoos bayOR97420P20182018040925.00375.00Oregon DOCRecords specialist* Earmarked Contribution: See Below  168 | SA11AIC00215905C11232795ABPACACTBLUEP.O. BOX 441146SOMERVILLEMA02144P20182018041525.008460.14Conduit total listed in Agg. fieldC00401224ACTBLUEXNote: Above Contribution earmarked through this organization. 169 | SA11CC00215905C11233012PACAECOM PAC2020 K ST., NWSUITE 300WASHINGTONDC20006G2018201804132500.008500.00C00374447AECOM PAC 170 | SA11CC00215905C11233015PACAMERICAN COMMERCIAL LINES INC. PAC1701 EAST MARKET STREETJEFFERSONVILLEIN47130P2018201804181000.001000.00C00418269AMERICAN COMMERCIAL LINES INC. PAC 171 | SA11CC00215905C11233023PACAMERICAN MARITIME OFFICERS VOLUNTARY POLITICAL ACTION FUNDP.O. BOX 66DANIA BEACHFL33004G2018201804182500.007500.00C00027532AMERICAN MARITIME OFFICERS VOLUNTARY POLITICAL ACTION FUND 172 | SA11CC00215905C11233020PACAMERICAN WATERWAYS OPERATORS-PAC801 N. QUINCY STREET, SUITE 200ARLINGTONVA22203P2018201804185000.007000.00C00034678AMERICAN WATERWAYS OPERATORS-PACredesignation of excess contribution pending written donor authorization 173 | SA11CC00215905C11233019PACCANAL BARGE COMPANY INC PAC (CANAL BARGE PAC)835 UNION STREETNEW ORLEANSLA70112P2018201804181000.001000.00C00541110CANAL BARGE COMPANY INC PAC (CANAL BARGE PAC) 174 | SA11CC00215905C11233011PACCROWLEY MARITIME CORPORATION FEDERAL PAC9487 REGENCY SQUARE BLVD.JACKSONVILLEFL32225P2018201804122500.005000.00C00147231CROWLEY MARITIME CORPORATION FEDERAL PAC 175 | SA11CC00215905C11233426PACFEDEX CORPORATION POLITICAL ACTION COMMITTEE (FEDEXPAC)942 S SHADY GROVE ROADMEMPHISTN38120P2018201804234000.005000.00C00068692FEDEX CORPORATION POLITICAL ACTION COMMITTEE (FEDEXPAC) 176 | SA11CC00215905C11233427PACGRANITE CONSTRUCTION INC. EMPLOYEE PAC - GRANITEPAC555 CAPITOL MALL, SUITE 400SACRAMENTOCA95814P2018201804232500.002500.00C00337394GRANITE CONSTRUCTION INC. EMPLOYEE PAC - GRANITEPAC 177 | SA11CC00215905C11155154PACINGRAM BARGE COMPANY POLITICAL ACTION COMMITTEEONE BELLE MEADE PL 4400 HARDING RDNASHVILLETN37205P2018201804042500.002500.00C00364471INGRAM BARGE COMPANY POLITICAL ACTION COMMITTEE 178 | SA11CC00215905C11233429PACK&L GATES LLP POLITICAL ACTION COMMITTEE (DC)1601 K STREET, NWWASHINGTONDC20006P2018201804231000.004000.00C00213173K&L GATES LLP POLITICAL ACTION COMMITTEE (DC) 179 | SA11CC00215905C11233021PACKIRBY CORPORATION POLITICAL ACTION COMMITTEE55 WAUGH DRIVESUITE 1000HOUSTONTX77007P2018201804182500.003500.00C00250027KIRBY CORPORATION POLITICAL ACTION COMMITTEE 180 | SA11CC00215905C11155155PACMORAN TOWING CORPORATION POLITICAL ACTION COMMITTEE50 LOCUST AVENUENEW CANAANCT06840P2018201804041000.001000.00C00477109MORAN TOWING CORPORATION POLITICAL ACTION COMMITTEE 181 | SA11CC00215905C11233428PACOLDCASTLE MATERIALS INC. PAC800 MAINE AVENUE SWSUITE 800WASHINGTONDC20024G2018201804231000.007500.00C00346353OLDCASTLE MATERIALS INC. PAC 182 | SA11CC00215905C11233010PACPARSONS CORPORATION POLITICAL ACTION COMMITTEE100 WEST WALNUT ST.T-1110PASADENACA91124P2018201804132500.005000.00C00103549PARSONS CORPORATION POLITICAL ACTION COMMITTEE 183 | SA11CC00215905C11233009PACSALTCHUK RESOURCES, INC. PAC1111 FAIRVIEW AVENUE NORTHACCOUNTING DEPARTMENTSEATTLEWA98109P2018201804101000.001000.00C00411694SALTCHUK RESOURCES, INC. PAC 184 | SA11CC00215905C11233018PACTIDEWATER HOLDINGS INC PAC6305 NW OLD LOWER RIVER ROADVANCOUVERWA98660P2018201804181000.001000.00C00450734TIDEWATER HOLDINGS INC PAC 185 | SA11CC00215905C11233189PACVAQUERO PAC1150 N LOOP 1604 WSTE 108 - 230SAN ANTONIOTX78248G2018201804161653.416653.41C00570622VAQUERO PAC* In-Kind: travel and catering expenses for fundraising activities 186 | SA11CC00215905C11233014PACWSP USA INC. PAC1015 HALF STREET, SESUITE 650WASHINGTONDC20003P2018201804161500.005500.00C00287003WSP USA INC. PAC 187 | SA11CC00215905C11233013PACWSP USA INC. PAC1015 HALF STREET, SESUITE 650WASHINGTONDC20003G201820180416500.005500.00C00287003WSP USA INC. PAC 188 | SA14C00215905C11233430ORGTotal Wine and More6240 Little River TurnpikeAlexandriaVA223121714P201820180421220.00220.00 189 | SB17C00215905D1070464ORG7 Devils Brewing Co.247 S Second StreetCoos BayOR97420P201820180421908.80catering for campaign event007 190 | SB17C00215905D1021019ORGActBlue Technical Services366 Summer StreetSomervilleMA02144P20182018040155.43merchant processing fees001 191 | SB17C00215905D1070318ORGActBlue Technical Services366 Summer StreetSomervilleMA02144P20182018040863.76merchant processing fees001 192 | SB17C00215905D1070319ORGActBlue Technical Services366 Summer StreetSomervilleMA02144P201820180415139.20merchant processing fees001 193 | SB17C00215905D1070320ORGActBlue Technical Services366 Summer StreetSomervilleMA02144P20182018042254.00merchant processing fees001 194 | SB17C00215905D1070488ORGActBlue Technical Services366 Summer StreetSomervilleMA02144P20182018042521.96merchant processing fees001 195 | SB17C00215905D1070491ORGAmerican Airlines4255 Amon Carter BoulevardFort WorthTX76155P201820180422760.60airfare002 196 | SB17C00215905D1070321ORGC&E SystemsPO Box 42307PortlandOR97242P2018201804201197.15FEC and IRS compliance001 197 | SB17C00215905D1021487ORGCardinal Services, Inc405 Lincoln StEugeneOR974012516P20182018041346.00payroll production001 198 | SB17C00215905D1021486INDDameronSierraRenee564 W. 28th Ave.EugeneOR97405P2018201804131291.47wages001 199 | SB17C00215905D1021485INDGabrielsonCarlyE1511 Elkay DrEugeneOR974043070P2018201804131856.11wages001 200 | SB17C00215905D1070472ORGHomeaway1011 West Fifth StreetSuite 300AustinTX78703P2018201804221119.25lodging002 201 | SB17C00215905D1070473ORGHomeaway1011 West Fifth StreetSuite 300AustinTX78703P20182018042259.00travel insurance002 202 | SB17C00215905D1070463ORGHotels.Com, LP10440 N Central ExpySte 400DallasTX752312228P201820180425208.19lodging002 203 | SB17C00215905D1070477ORGLane Community College4000 East 30th Ave.EugeneOR97405P201820180405270.00community forum venue007 204 | SB17C00215905D1021461ORGMandate MediaPO Box 80151PortlandOR97280P2018201804052350.00web consulting, email services001 205 | SB17C00215905D1021476ORGMaple Investments975 Oak StSte 1050EugeneOR974013124P201820180401300.00office rent001 206 | SB17C00215905D1070469ORGMenus Catering655 Taylor St NEWashingtonDC200172063P201820180401431.64catering003 207 | SB17C00215905D1021474ORGNational Democratic Club30 Ivy St SEWashingtonDC200034006P2018201804111084.40catering003 208 | SB17C00215905D1070467ORGNGP VAN, Inc.1101 15th St NWSte 500WashingtonDC200055006P201820180401550.00database services001 209 | SB17C00215905D1070479ORGOregon League of Conservation Voters133 SW 2nd AveSuite 200PortlandOR972043524P201820180405416.67event sponsorship and attendance007 210 | SB17C00215905D1070485ORGOregon Lithoprint, Inc.PO Box 727McMinnvilleOR97128P2018201804173000.00periodical advertising004 211 | SB17C00215905D1070465ORGRSVP Catering2930 Prosperity AveFairfaxVA22031P201820180425208.05catering for event003 212 | SB17C00215905D1070487ORGSAIF Corporation400 High St SESalemOR973120700P201820180407109.06workers compensation insurance001 213 | SB17C00215905D1021473ORGSanipac1480 Glenwood BlvdSpringfieldOR97477P20182018041147.87garbage and recycling001 214 | SB17C00215905D1021477ORGStorItAll550 E 8th AveEugeneOR974013344P201820180401180.00storage rent001 215 | SB17C00215905D1021479ORGSunday Properties, LLC2677 Willakenzie RdSte 2EugeneOR974014873P20182018040150.00storage rent001 216 | SB17C00215905D1021436ORGThe Frost Group3701 Porter St NWWashingtonDC200163103P2018201804015500.00fundraising consulting003 217 | SB17C00215905D1070466ORGThe Salt Line79 Potomac Ave SEWashingtonDC20003P201820180412359.20catering for event003 218 | SB17C00215905D1070461ORGTotal Wine and More6240 Little River TurnpikeAlexandriaVA223121714P201820180415668.87catering for campaign event007 219 | SB17C00215905D1070462ORGTotal Wine and More6240 Little River TurnpikeAlexandriaVA223121714P201820180417220.23catering for campaign event007 220 | SB17C00215905D1070478ORGUnited Brotherhood of Carpenters101 Constitution Ave NWatt: Jean KabreWashingtonDC200012133P201820180405300.00room use fee003 221 | SB17C00215905D1070484ORGUnited States TreasuryInternal Revenue ServiceOgdenUT84201P20182018041113.70federal taxes - Form 1120POL 2018001 222 | SB17C00215905D1070471ORGUS Postmaster760 A StSpringfieldOR974779998P201820180409524.70postage001 223 | SB17C00215905D1070404C11233189SA11CPACVAQUERO PAC1150 N LOOP 1604 WSTE 108 - 230SAN ANTONIOTX78248G2018201804161653.41travel and catering expenses for fundraising activitiesC00570622* In-Kind Received 224 | SB17C00215905D1021482ORGCardinal Services, Inc405 Lincoln StEugeneOR974012516P2018201804131598.07payroll taxes per detail001 225 | SB17C00215905D1021483D1021482SB17ORGOregon Department of RevenuePO Box 14800SalemOR973090920P201820180413465.85state payroll taxes001X 226 | SB17C00215905D1021484D1021482SB17ORGUnited States TreasuryInternal Revenue ServiceOgdenUT84201P2018201804131132.22federal payroll taxes001X 227 | SB17C00215905D1070474CANDeFazioPeterA.PO Box 1316SpringfieldOR974770152P20182018040448.64reimburse travel expense002H6OR04047DeFazioPeterA.HOR04 228 | SB17C00215905D1070475CANDeFazioPeterA.PO Box 1316SpringfieldOR974770152P20182018040488.12reimburse travel expense002H6OR04047DeFazioPeterA.HOR04 229 | SB17C00215905D1070493D1070475SB17ORGHotel Modera515 SW Clay StPortlandOR972015407P20182018031188.12lodging - reimbursement detail002X 230 | SB17C00215905D1070476CANDeFazioPeterA.PO Box 1316SpringfieldOR974770152P20182018040415.00reimburse travel expense002H6OR04047DeFazioPeterA.HOR04 231 | SB17C00215905D1070494D1070476SB17ORGHotel Modera515 SW Clay StPortlandOR972015407P20182018031115.00lodging002X 232 | SB17C00215905D1070481ORGThe Frost Group3701 Porter St NWWashingtonDC200163103P201820180405232.64reimburse shipping and fundraising expense per detail003 233 | SB17C00215905D1070483D1070481SB17ORGFedEx Office - 2nd St208 2nd St SEWashingtonDC20003P201820180402172.50shipping - reimbursement detail003X 234 | SB20AC00215905D1070489ORGActBlue Technical Services366 Summer StreetSomervilleMA02144P20182018042530.00refund contribution via ActBlue010 235 | SB21C00215905D1070480ORGPlanned Parenthood Advocates of OregonPO Box 12267PortlandOR97212P2018201804051000.00event sponsorship012 236 | -------------------------------------------------------------------------------- /test-data/1236235.fec: -------------------------------------------------------------------------------- 1 | HDRFEC8.2NEA Fund for Children and Public Education3.10 2 | F99C00003251NEA Fund for Children and Public Education1201 16th Street NW Suite418WashingtonDC20036McPhersonMichael20180604MST 3 | 4 | [BEGINTEXT] 5 | 6 | June 4, 2018 7 | 8 | Mr. Christopher Morse 9 | Sr. Campaign Finance Analyst 10 | Reports Analysis Division 11 | Federal Election Commission 12 | 1050 First St. NE 13 | Washington, DC 20463 14 | 15 | Re:ID# C00003251, Request for Additional Information - Amended March Monthly Report (02/01/2018 � 02/28/2018) 16 | 17 | Dear Mr. Morse, 18 | 19 | We are in receipt of your Request for Additional Information (RFAI) dated May 2, 2018. While your letter 20 | acknowledged that we did provide an explanation about the disbursements disclosed on our amended 21 | March Monthly Report,you requested additional clarification. We welcome the opportunity to further 22 | clarify for the Commission and the public record our on-going efforts to file accurate reports. 23 | 24 | NEA Fund for Children and Public Education seeks to comply with all federal, state and local campaign 25 | finance regulations as applicable based on our activity. We work with our vendor to insure timely and 26 | accurate filings. To that end, a monthly reconciliation of the PAC bank account showed that - due 27 | to a previously undetected administrative error - there were disbursements made in February, 2018 that were not 28 | reported on the March Monthly report. The report containing the error was promptly amended and we have taken steps with our 29 | vendor to ensure that such and occurrence does not happen again. 30 | 31 | We trust that this letter adequately responds to your inquiry. If you have any further questions, please 32 | contact us. 33 | 34 | 35 | Respectfully submitted, 36 | 37 | Michael McPherson 38 | Treasurer 39 | NEA Fund for Children and Public Education 40 | 41 | [ENDTEXT] 42 | -------------------------------------------------------------------------------- /test-data/1260488.fec: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/esonderegger/fecfile/0ac4f0372d4eddedd6bde850cd73c092a5ffc76b/test-data/1260488.fec -------------------------------------------------------------------------------- /test-data/1385191.fec: -------------------------------------------------------------------------------- 1 | HDRFEC8.3NGP8 2 | F3PNC00693234Warren for President, Inc.124 Washington StreetSuite 101FoxboroMA02035XXM22020010120200131EgermanPaul2020022013715309.0611030669.0624745978.1222445998.022299980.100.00400000.000.0081024695.4689430381.800.005191564.005215093.1810406657.180.0015.000.0010406672.180.00400000.000.00400000.00220374.600.000.00220374.603622.2811030669.0622322012.600.000.000.000.000.000.00111018.940.0033.00111051.9412933.4822445998.020.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.0033014241.8848480591.5281494833.400.001436.005777.5081502046.9010415000.00400000.000.00400000.00559938.060.000.00559938.06151109.8893028094.8489990319.860.000.000.000.000.000.00477315.440.0036.00477351.44260443.4490728114.740.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.000.00 3 | SC/12C006932346071527L19AORGAmalgamated Bank275 7Th AveNew YorkNY100016708P2020400000.000.00400000.0020200121202107010.0600YN 4 | SC2/12C006932346071527G6071527LWarrenElizabeth124 Washington StSte 101FoxboroMA020351368U.S. GovernmentSenator400000.00 5 | SC1/12C006932346071527BL6071527LAmalgamated Bank275 7 Seventh AvenueNew YorkNY100013000000.000.06002020012120210701N400000.00400000.00YYCurrent and Future Assets3000000.00YYContributions Receivable3000000.0020190102Amalgamated Bank275 Seventh AvenueNew YorkNY10001EgermanPaul20200220PetersonWilliamSr Vice President20200220 6 | -------------------------------------------------------------------------------- /test-data/20180616.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/esonderegger/fecfile/0ac4f0372d4eddedd6bde850cd73c092a5ffc76b/test-data/20180616.zip -------------------------------------------------------------------------------- /tests.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import fecfile 3 | from datetime import datetime 4 | import os 5 | import json 6 | import shutil 7 | import zipfile 8 | import random 9 | import sys 10 | import warnings 11 | 12 | 13 | class CandidateTest(unittest.TestCase): 14 | def test_simple(self): 15 | parsed = {} 16 | with open('test-data/1229017.fec') as file: 17 | unparsed = file.read() 18 | parsed = fecfile.loads(unparsed) 19 | self.assertEqual(parsed['filing']['report_code'], '12P') 20 | filing = parsed['filing'] 21 | self.assertEqual(filing['col_a_cash_on_hand_close'], 1141844.62) 22 | self.assertIsInstance(filing['date_signed'], datetime) 23 | self.assertEqual(len(parsed['itemizations']['Schedule A']), 186) 24 | self.assertEqual(len(parsed['itemizations']['Schedule B']), 47) 25 | 26 | 27 | class PacViaHttpRequest(unittest.TestCase): 28 | def test_request(self): 29 | parsed = fecfile.from_http(1232195) 30 | self.assertEqual(parsed['filing']['report_code'], 'M5') 31 | self.assertEqual(parsed['filing']['state'], 'DC') 32 | self.assertEqual(len(parsed['itemizations']['Schedule A']), 5) 33 | self.assertEqual(len(parsed['itemizations']['Schedule B']), 8) 34 | 35 | 36 | class TextLastRow(unittest.TestCase): 37 | def test_request(self): 38 | parsed = fecfile.from_http(1232188) 39 | self.assertEqual(parsed['filing']['report_code'], 'M5') 40 | self.assertEqual(parsed['filing']['state'], 'NJ') 41 | self.assertEqual(len(parsed['itemizations']['Schedule A']), 1) 42 | self.assertEqual(len(parsed['itemizations']['Schedule B']), 11) 43 | self.assertEqual(len(parsed['text']), 1) 44 | 45 | 46 | class IndependentExpendituresReport(unittest.TestCase): 47 | def test_request(self): 48 | parsed = fecfile.from_http(1146148) 49 | self.assertEqual(parsed['filing']['report_code'], 'YE') 50 | self.assertEqual(parsed['filing']['state'], 'DC') 51 | self.assertEqual(len(parsed['itemizations']['F57']), 5) 52 | 53 | 54 | class HasScheduleC(unittest.TestCase): 55 | def test_request(self): 56 | parsed = fecfile.from_http(1229012) 57 | sched_c = parsed['itemizations']['Schedule C'][0] 58 | self.assertEqual(sched_c['loan_balance'], 30000.00) 59 | 60 | class HandleScheduleCDates(unittest.TestCase): 61 | def test_dates(self): 62 | file_path = 'test-data/1385191.fec' 63 | parsed = fecfile.from_file(file_path) 64 | 65 | sched_c = parsed['itemizations']['Schedule C'][0] 66 | self.assertIsInstance(sched_c['loan_incurred_date_terms'], datetime) 67 | 68 | sched_c = parsed['itemizations']['Schedule C'][2] 69 | self.assertIsInstance(sched_c['loan_incurred_date'], datetime) 70 | self.assertIsInstance(sched_c['loan_due_date'], str) 71 | self.assertIsInstance(sched_c['established_date'], datetime) 72 | self.assertIsInstance(sched_c['date_signed'], datetime) 73 | self.assertIsInstance(sched_c['authorized_date'], datetime) 74 | self.assertIsNone(sched_c['deposit_acct_auth_date_presidential']) 75 | self.assertIsNone(sched_c['loan_incurred_date_original']) 76 | 77 | class HasScheduleD(unittest.TestCase): 78 | def test_request(self): 79 | parsed = fecfile.from_http(1146147) 80 | sched_d = parsed['itemizations']['Schedule D'][0] 81 | self.assertEqual(sched_d['balance_at_close_this_period'], 26622.00) 82 | 83 | 84 | class HasScheduleI(unittest.TestCase): 85 | def test_request(self): 86 | parsed = fecfile.from_http(99840, {'filter_itemizations': ['SI']}) 87 | sched_i = parsed['itemizations']['Schedule I'][0] 88 | self.assertEqual(sched_i['col_a_subtotal'], 99592.46) 89 | 90 | 91 | class HandleF1FromWebForms(unittest.TestCase): 92 | def test_request(self): 93 | parsed = fecfile.from_http(1229011) 94 | self.assertEqual(parsed['header']['fec_version'], '8.2') 95 | self.assertEqual(parsed['filing']['treasurer_city'], 'Philadelphia') 96 | self.assertIsInstance(parsed['filing']['effective_date'], datetime) 97 | 98 | 99 | class HandlePaperF1M(unittest.TestCase): 100 | def test_request(self): 101 | parsed = fecfile.from_http(1101469) 102 | self.assertEqual(parsed['header']['fec_version'], 'P3.2') 103 | self.assertEqual(parsed['filing']['city'], 'LUBBOCK') 104 | self.assertIsInstance(parsed['filing']['date_signed'], datetime) 105 | 106 | 107 | class HandleSpaceInFormType(unittest.TestCase): 108 | def test_request(self): 109 | parsed = fecfile.from_http(807197) 110 | self.assertEqual(parsed['header']['fec_version'], 'P2.6') 111 | self.assertEqual(parsed['filing']['street_1'], '21 NOB HILL DRIVE') 112 | 113 | 114 | class HandlePercentInNumber(unittest.TestCase): 115 | def test_request(self): 116 | parsed = fecfile.from_http(1235309) 117 | self.assertEqual(parsed['header']['fec_version'], '8.2') 118 | loan_itemization = parsed['itemizations']['Schedule C'][3] 119 | self.assertEqual(loan_itemization['loan_interest_rate'], '5.00%') 120 | 121 | 122 | class HandleNANumber(unittest.TestCase): 123 | def test_request(self): 124 | parsed = fecfile.from_http(1223616) 125 | self.assertEqual(parsed['filing']['committee_name'], 'Leann for Iowa') 126 | loan_itemization = parsed['itemizations']['Schedule C'][0] 127 | self.assertEqual(loan_itemization['loan_interest_rate_terms'], 'N/A') 128 | 129 | 130 | class F99Filing(unittest.TestCase): 131 | def test_request(self): 132 | parsed = fecfile.from_http(1090014) 133 | self.assertEqual(parsed['header']['fec_version'], '8.1') 134 | self.assertEqual( 135 | parsed['filing']['committee_name'], 136 | 'KENT FOR CONGRESS', 137 | ) 138 | expected = 'Termination of Campaign. Did not exceed $5000 threshold.' 139 | self.assertEqual(parsed['F99_text'], expected) 140 | 141 | 142 | class ConvertZipFileToJSON(unittest.TestCase): 143 | def test_convert(self): 144 | date_str = '20180616' 145 | z_file = 'test-data/{d}.zip'.format(d=date_str) 146 | fec_dir = 'test-data/{d}-fec'.format(d=date_str) 147 | os.mkdir(fec_dir) 148 | json_dir = 'test-data/{d}-json'.format(d=date_str) 149 | os.mkdir(json_dir) 150 | with zipfile.ZipFile(z_file, 'r') as zip_ref: 151 | zip_ref.extractall(fec_dir) 152 | files = os.listdir(fec_dir) 153 | num_files = len(files) 154 | for f in sorted(files): 155 | parsed = fecfile.from_file(fec_dir + '/' + f) 156 | self.assertIsInstance(parsed['filing']['date_signed'], datetime) 157 | outpath = json_dir + '/' + f[0:-3] + 'json' 158 | with open(outpath, 'w') as outf: 159 | outf.write( 160 | json.dumps(parsed, sort_keys=True, indent=2, default=str) 161 | ) 162 | new_files = os.listdir(json_dir) 163 | self.assertEqual(len(new_files), num_files) 164 | shutil.rmtree(fec_dir) 165 | shutil.rmtree(json_dir) 166 | 167 | 168 | class SenatePaperFiling(unittest.TestCase): 169 | def test_request(self): 170 | parsed = fecfile.from_http(1226815) 171 | filing = parsed['filing'] 172 | self.assertEqual(filing['committee_name'], 'FRIENDS OF MARIA') 173 | first_a = parsed['itemizations']['Schedule A'][0] 174 | self.assertEqual(first_a['contribution_amount'], 25.0) 175 | 176 | 177 | class CanParsePaperF3Z(unittest.TestCase): 178 | def test_request(self): 179 | parsed = fecfile.from_http(1160224) 180 | filing = parsed['filing'] 181 | self.assertEqual( 182 | filing['committee_name'], 183 | 'BOBBY MAHENDRA FOR SENATE' 184 | ) 185 | f3z = parsed['itemizations']['F3Z'] 186 | self.assertEqual(f3z[0]['col_a_net_contributions'], 459.75) 187 | 188 | 189 | class CanParseF8(unittest.TestCase): 190 | def test_request(self): 191 | parsed = fecfile.from_http(245235) 192 | self.assertEqual( 193 | parsed['filing']['committee_name'], 194 | 'ELECT KEVIN NESTOR TO CONGRESS COMMITTEE' 195 | ) 196 | self.assertEqual(parsed['filing']['total_assets'], 93.8) 197 | f8ii = parsed['itemizations']['F8II'] 198 | self.assertEqual(len(f8ii), 3) 199 | self.assertEqual(f8ii[1]['amount_owed_to'], 40000) 200 | 201 | 202 | class CanParseF10(unittest.TestCase): 203 | def test_request(self): 204 | parsed = fecfile.from_http(234569) 205 | self.assertEqual( 206 | parsed['filing']['committee_name'], 207 | 'COMMITTEE TO ELECT ALAN GRAYSON' 208 | ) 209 | self.assertEqual( 210 | parsed['filing']['expenditure_total_cycle_to_date'], 211 | 430400 212 | ) 213 | f105 = parsed['itemizations']['F105'] 214 | self.assertEqual(len(f105), 2) 215 | self.assertEqual(f105[0]['expenditure_amount'], 5400) 216 | 217 | 218 | class InauguralCommitteeFiling(unittest.TestCase): 219 | def test_request(self): 220 | parsed = fecfile.from_http(1160672) 221 | filing = parsed['filing'] 222 | comm_name = '58TH PRESIDENTIAL INAUGURAL COMMITTEE' 223 | self.assertEqual(filing['committee_name'], comm_name) 224 | first_itemization = parsed['itemizations']['F132'][0] 225 | self.assertEqual(first_itemization['donation_amount'], 100.0) 226 | 227 | 228 | class ElectioneeringFiling(unittest.TestCase): 229 | def test_request(self): 230 | parsed = fecfile.from_http(1226989) 231 | filing = parsed['filing'] 232 | self.assertEqual(filing['organization_name'], '45Committee, Inc.') 233 | self.assertEqual(filing['total_disbursements'], 56678.84) 234 | first_91 = parsed['itemizations']['F91'][0] 235 | self.assertEqual(first_91['controller_city'], 'Herndon') 236 | first_93 = parsed['itemizations']['F93'][0] 237 | self.assertEqual(first_93['expenditure_amount'], 48017.00) 238 | first_94 = parsed['itemizations']['F94'][0] 239 | self.assertEqual(first_94['candidate_last_name'], 'Manchin') 240 | 241 | 242 | class Form3SFiling(unittest.TestCase): 243 | def test_request(self): 244 | parsed = fecfile.from_http(1156717) 245 | summary = parsed['itemizations']['F3S'][0] 246 | self.assertEqual(summary['a_total_contributions_no_loans'], 11469.22) 247 | self.assertEqual(summary['total_disbursements'], 55324.77) 248 | 249 | 250 | class WhiteSpaceNullFields(unittest.TestCase): 251 | def test_request(self): 252 | with warnings.catch_warnings(record=True) as w: 253 | parsed = fecfile.from_http(476351) 254 | filing = parsed['filing'] 255 | self.assertEqual(filing['report_code'], '12P') 256 | self.assertEqual(len(w), 0) 257 | 258 | 259 | class UnnecessaryQuotes(unittest.TestCase): 260 | def test_request(self): 261 | parsed = fecfile.from_http(1157513) 262 | filing = parsed['filing'] 263 | comm_name = 'Friends of Dave Brat Inc.' 264 | self.assertEqual(filing['committee_name'], comm_name) 265 | first_itemization = parsed['itemizations']['Schedule A'][0] 266 | self.assertEqual(first_itemization['contribution_amount'], 1500.0) 267 | 268 | 269 | class V5Filing(unittest.TestCase): 270 | def test_request(self): 271 | parsed = fecfile.from_http(92888) 272 | filing = parsed['filing'] 273 | self.assertEqual( 274 | filing['committee_name'], 275 | 'Mecklenburg County Republican Party' 276 | ) 277 | sched_b = parsed['itemizations']['Schedule B'] 278 | self.assertEqual(len(sched_b), 5) 279 | self.assertEqual(sched_b[0]['expenditure_amount'], 500.0) 280 | 281 | 282 | class V3Filing(unittest.TestCase): 283 | def test_request(self): 284 | parsed = fecfile.from_http(52888) 285 | filing = parsed['filing'] 286 | self.assertEqual( 287 | filing['committee_name'], 288 | 'KEEGAN 2002' 289 | ) 290 | sched_b = parsed['itemizations']['Schedule B'] 291 | self.assertEqual(len(sched_b), 55) 292 | self.assertEqual(sched_b[0]['expenditure_amount'], 243.84) 293 | 294 | 295 | class CommaInCSVFiling(unittest.TestCase): 296 | def test_request(self): 297 | parsed = fecfile.from_http(22888) 298 | filing = parsed['filing'] 299 | self.assertEqual( 300 | filing['committee_name'], 301 | 'PHOENIX FIRE FIGHTERS, LOCAL 493, FIRE PAC COMMITTEE' 302 | ) 303 | sched_b = parsed['itemizations']['Schedule B'] 304 | self.assertEqual(len(sched_b), 48) 305 | self.assertEqual(sched_b[0]['expenditure_amount'], 250.0) 306 | 307 | 308 | class V2Filing(unittest.TestCase): 309 | def test_request(self): 310 | parsed = fecfile.from_http(12888) 311 | filing = parsed['filing'] 312 | self.assertEqual( 313 | filing['committee_name'], 314 | 'Defend America PAC' 315 | ) 316 | sched_b = parsed['itemizations']['Schedule B'] 317 | self.assertEqual(len(sched_b), 6) 318 | self.assertEqual(sched_b[0]['expenditure_amount'], 1802.0) 319 | 320 | 321 | class V1Filing(unittest.TestCase): 322 | def test_request(self): 323 | parsed = fecfile.from_http(130) 324 | filing = parsed['filing'] 325 | self.assertEqual(filing['filer_committee_id_number'], 'C00252791') 326 | sched_b = parsed['itemizations']['Schedule B'] 327 | self.assertEqual(len(sched_b), 4) 328 | self.assertEqual(sched_b[0]['expenditure_amount'], 286.61) 329 | 330 | 331 | class Windows1252Encoding(unittest.TestCase): 332 | def test_read(self): 333 | file_path = 'test-data/1260488.fec' 334 | parsed = fecfile.from_file(file_path) 335 | self.assertIsInstance(parsed['filing']['date_signed'], datetime) 336 | self.assertEqual(parsed['filing']['city'], 'Denton') 337 | 338 | 339 | class OptionsFilterItemizations(unittest.TestCase): 340 | def test_read(self): 341 | file_path = 'test-data/1229017.fec' 342 | a_filter = {'filter_itemizations': ['SB']} 343 | parsed = fecfile.from_file(file_path, options=a_filter) 344 | self.assertEqual(parsed['filing']['report_code'], '12P') 345 | self.assertEqual(len(parsed['itemizations']['Schedule B']), 47) 346 | self.assertNotIn('Schedule A', parsed['itemizations']) 347 | 348 | 349 | class AsStringsOption(unittest.TestCase): 350 | def test_request(self): 351 | parsed = fecfile.from_http(1223458, options={'as_strings': True}) 352 | filing = parsed['filing'] 353 | self.assertEqual(filing['committee_name'], 'MARGO FOR CONGRESS') 354 | self.assertEqual(filing['col_b_total_receipts'], '29916.00') 355 | sched_b = parsed['itemizations']['Schedule B'] 356 | self.assertEqual(len(sched_b), 5) 357 | self.assertEqual(sched_b[0]['expenditure_amount'], '984.00') 358 | 359 | 360 | class ParseHttpIterator(unittest.TestCase): 361 | def test_parse(self): 362 | file_num = 1000 363 | a_filter = {'filter_itemizations': ['SB']} 364 | items = fecfile.iter_http(file_num, options=a_filter) 365 | num_itemizations = 0 366 | for item in items: 367 | if item.data_type == 'summary': 368 | self.assertEqual(item.data['report_code'], '12G') 369 | if item.data_type == 'itemization': 370 | num_itemizations += 1 371 | self.assertEqual(num_itemizations, 48) 372 | 373 | 374 | class ParseFileIterator(unittest.TestCase): 375 | def test_parse(self): 376 | file_path = 'test-data/1229017.fec' 377 | a_filter = {'filter_itemizations': ['SA']} 378 | items = fecfile.iter_file(file_path, options=a_filter) 379 | num_itemizations = 0 380 | for item in items: 381 | if item.data_type == 'summary': 382 | self.assertEqual(item.data['report_code'], '12P') 383 | if item.data_type == 'itemization': 384 | num_itemizations += 1 385 | self.assertEqual(num_itemizations, 186) 386 | 387 | 388 | class AllFormsHaveMappings(unittest.TestCase): 389 | def test_request(self): 390 | missing_mappings = {} 391 | whole_range = list(range(0, 1288000)) 392 | random_sample = random.sample(whole_range, 100) 393 | for i in random_sample: 394 | try: 395 | fecfile.from_http(i) 396 | except fecfile.FecParserMissingMappingError as ex: 397 | print(str(i) + ': ' + str(ex)) 398 | relevant_str = str(ex)[13:].split(' - ')[0] 399 | if relevant_str in missing_mappings: 400 | missing_mappings[relevant_str] += 1 401 | else: 402 | missing_mappings[relevant_str] = 1 403 | for m in sorted(missing_mappings.keys()): 404 | print('{a} ({b})'.format(a=m, b=missing_mappings[m])) 405 | self.assertEqual(len(missing_mappings.keys()), 0) 406 | 407 | 408 | if __name__ == '__main__': 409 | regular_tests = unittest.TestSuite([ 410 | CandidateTest('test_simple'), 411 | PacViaHttpRequest('test_request'), 412 | TextLastRow('test_request'), 413 | IndependentExpendituresReport('test_request'), 414 | HasScheduleC('test_request'), 415 | HandleScheduleCDates('test_dates'), 416 | HasScheduleD('test_request'), 417 | HasScheduleI('test_request'), 418 | HandleF1FromWebForms('test_request'), 419 | HandlePaperF1M('test_request'), 420 | HandleSpaceInFormType('test_request'), 421 | HandlePercentInNumber('test_request'), 422 | HandleNANumber('test_request'), 423 | F99Filing('test_request'), 424 | ConvertZipFileToJSON('test_convert'), 425 | SenatePaperFiling('test_request'), 426 | CanParsePaperF3Z('test_request'), 427 | CanParseF8('test_request'), 428 | CanParseF10('test_request'), 429 | InauguralCommitteeFiling('test_request'), 430 | ElectioneeringFiling('test_request'), 431 | Form3SFiling('test_request'), 432 | WhiteSpaceNullFields('test_request'), 433 | UnnecessaryQuotes('test_request'), 434 | V5Filing('test_request'), 435 | V3Filing('test_request'), 436 | CommaInCSVFiling('test_request'), 437 | V2Filing('test_request'), 438 | V1Filing('test_request'), 439 | Windows1252Encoding('test_read'), 440 | OptionsFilterItemizations('test_read'), 441 | AsStringsOption('test_request'), 442 | ParseHttpIterator('test_parse'), 443 | ParseFileIterator('test_parse'), 444 | ]) 445 | mappings_test = unittest.TestSuite([AllFormsHaveMappings('test_request')]) 446 | if len(sys.argv) > 1 and sys.argv[1] == 'mappings': 447 | unittest.TextTestRunner().run(mappings_test) 448 | else: 449 | unittest.TextTestRunner().run(regular_tests) 450 | --------------------------------------------------------------------------------