offensivepolitics-fechell 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +73 -10
- data/Rakefile +2 -2
- data/fechell.gemspec +3 -3
- data/lib/defs/5.3.csv +1 -1
- data/lib/defs/6.1.csv +1 -1
- data/lib/defs/6.2.csv +1 -1
- data/lib/defs/6.3.csv +1 -1
- data/lib/defs/6.4.csv +1 -1
- data/lib/fechell.rb +3 -2
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -8,21 +8,83 @@ sudo gem install offensivepolitics-fechell
|
|
8
8
|
|
9
9
|
== Usage
|
10
10
|
|
11
|
-
|
12
|
-
|
11
|
+
require 'rubygems'
|
12
|
+
require 'fechell'
|
13
|
+
require 'open-uri'
|
13
14
|
|
14
|
-
|
15
|
+
# convenience function to download a file from a URL and save it locally
|
16
|
+
|
17
|
+
def savefile(filename,url)
|
18
|
+
File.open(filename,"w") do |file|
|
19
|
+
file.puts open(url).read
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
h = FECHell.new
|
24
|
+
|
25
|
+
# Grab the year-end fundraising reports by candidates for the 5th district of Virginia. This race was incredibly close and decided by less than 800 votes.
|
26
|
+
|
27
|
+
# fetch Goode for Congress F3, Year End 2008
|
28
|
+
savefile("goode.fec","http://query.nictusa.com/dcdev/posted/392684.fec")
|
29
|
+
|
30
|
+
# fetch Perriello for Congress F3, Year end 2008
|
31
|
+
savefile('perriello.fec',"http://query.nictusa.com/dcdev/posted/401630.fec")
|
32
|
+
|
33
|
+
# extract the financial summary of each campaign. we want total receipts this period and cycle to date, total disbursements this period and cycle to date,
|
34
|
+
# and the cash position at the beginning and end of this reporting period
|
35
|
+
|
36
|
+
['goode.fec','perriello.fec'].each do |filename|
|
37
|
+
h.process(filename) do |v|
|
38
|
+
schedule = v[0]
|
39
|
+
values = v[1]
|
40
|
+
next if schedule != 'F3'
|
41
|
+
puts "For '#{values['COMMITTEE NAME']}'"
|
42
|
+
|
43
|
+
|
44
|
+
puts "Total receipts this period: #{values['Column A 24. Total Receipts this Period']}"
|
45
|
+
puts "Total receipts cycle-to-date: #{values['Column B 16. Total Receipts']}"
|
46
|
+
puts "Total disbursements this period: #{values['Column A 26. Total Disbursements this Period']}"
|
47
|
+
puts "Total disbursements cycle-to-date: #{values['Column B 22. Total Disbursements']}"
|
48
|
+
puts "Cash-on-hand beginning of period: #{values['Column A 23. Cash Beginning Reporting Period']}"
|
49
|
+
puts "Cash-on-hand end of period: #{values['Column A 27. Cash on hand at Close Period']}"
|
50
|
+
puts "\n"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# From this output we see that Rep Goode outspent Perriello by more than a million dollars, but still lost his seat by 727 votes.
|
55
|
+
|
56
|
+
puts "==="
|
57
|
+
|
58
|
+
# fetch HuckPac F3X, Post General, 2008
|
59
|
+
savefile('huckpac.fec','http://query.nictusa.com/dcdev/posted/407479.fec')
|
60
|
+
# extract disbursements (schedule B) made this period by HuckPAC with the expenditure purpose(key="EXPENDITURE PURPOPOSE DESCRIPTION") of "Payroll"
|
61
|
+
puts "TO,DATE,AMOUNT"
|
62
|
+
h.process("huckpac.fec") do |v|
|
63
|
+
schedule = v[0]
|
64
|
+
values = v[1]
|
65
|
+
|
66
|
+
next if schedule != 'SB'
|
67
|
+
|
68
|
+
next if values['EXPENDITURE PURPOSE DESCRIP'] != 'Payroll'
|
69
|
+
|
70
|
+
puts "#{values['PAYEE FIRST NAME']} #{values['PAYEE LAST NAME']},#{values['EXPENDITURE DATE']},#{values['EXPENDITURE AMOUNT']}"
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
# From this we can see that HuckPAC keeps 5 full-time people on staff, including his daughter Sarah.
|
15
75
|
|
16
|
-
h.load('path_to.fec') do |line|
|
17
|
-
schedule = line[0]
|
18
|
-
values = line[1]
|
19
|
-
puts "line is a schedule #{schedule} with keys #{values.keys.join(',')}"
|
20
|
-
end
|
21
76
|
|
22
77
|
== Changes
|
23
|
-
0.1.
|
24
|
-
|
78
|
+
0.1.8
|
79
|
+
Prepended "Column A" or "Column B" to forms F3,F3P,F3X,F3Z for all FEC DEF files to accommodate duplicate key names.
|
80
|
+
Added HDR records to all the FEC DEF files
|
81
|
+
Updated schedule identifier to allow HDR (header) lines to pass through system
|
25
82
|
|
83
|
+
0.1.7
|
84
|
+
Added support for the FEC header line (schedule=HDR) to format files 5.0-6.4
|
85
|
+
|
86
|
+
0.1.6
|
87
|
+
Fixed version numbers in FECHell::Versions
|
26
88
|
|
27
89
|
0.1.5
|
28
90
|
Fixed optional 'options' parameter to FECHell::process() call
|
@@ -40,6 +102,7 @@ sudo gem install offensivepolitics-fechell
|
|
40
102
|
Added support for version 6.3 FEC files
|
41
103
|
|
42
104
|
== Todo
|
105
|
+
- Normalize KEY names in DEF files (NO vs No, etc)
|
43
106
|
- Support v3.0 electronic filing
|
44
107
|
- Better error checking on failed schedule identification.
|
45
108
|
- Convert Watchdog.net CSV files into ruby classes
|
data/Rakefile
CHANGED
@@ -2,12 +2,12 @@ require 'rubygems'
|
|
2
2
|
require 'rake'
|
3
3
|
require 'echoe'
|
4
4
|
|
5
|
-
Echoe.new('fechell', '0.1.
|
5
|
+
Echoe.new('fechell', '0.1.8') do |p|
|
6
6
|
p.description = "Parse electronically filed FEC reports."
|
7
7
|
p.url = "http://offensivepolitics.net/fechell"
|
8
8
|
p.author = "Jason Holt"
|
9
9
|
p.email = "jjh@offensivepolitics.net"
|
10
|
-
p.ignore_pattern = ["tmp/*", "script/*", "
|
10
|
+
p.ignore_pattern = ["tmp/*", "script/*", "./Manife*","pkg/*", "doc/*"]
|
11
11
|
p.development_dependencies = []
|
12
12
|
p.rdoc_pattern = ['README.rdoc']
|
13
13
|
p.runtime_dependencies = ['fastercsv']
|
data/fechell.gemspec
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{fechell}
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.8"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Jason Holt"]
|
9
|
-
s.date = %q{2009-
|
9
|
+
s.date = %q{2009-06-18}
|
10
10
|
s.description = %q{Parse electronically filed FEC reports.}
|
11
11
|
s.email = %q{jjh@offensivepolitics.net}
|
12
12
|
s.extra_rdoc_files = ["README.rdoc"]
|
13
|
-
s.files = ["fechell.gemspec", "lib/defs/3.00.csv", "lib/defs/5.00.csv", "lib/defs/5.1.csv", "lib/defs/5.2.csv", "lib/defs/5.3.csv", "lib/defs/6.1.csv", "lib/defs/6.2.csv", "lib/defs/6.3.csv", "lib/defs/6.4.csv", "lib/fechell.rb","Rakefile", "README.rdoc"]
|
13
|
+
s.files = ["fechell.gemspec", "lib/defs/3.00.csv", "lib/defs/5.00.csv", "lib/defs/5.1.csv", "lib/defs/5.2.csv", "lib/defs/5.3.csv", "lib/defs/6.1.csv", "lib/defs/6.2.csv", "lib/defs/6.3.csv", "lib/defs/6.4.csv", "lib/fechell.rb", "Rakefile", "README.rdoc"]
|
14
14
|
s.has_rdoc = true
|
15
15
|
s.homepage = %q{http://offensivepolitics.net/fechell}
|
16
16
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Fechell", "--main", "README.rdoc"]
|
data/lib/defs/5.3.csv
CHANGED
@@ -1 +1 @@
|
|
1
|
-
F1;FORM TYPE;FILER FEC CMTE ID ;COMMITTEE NAME;STREET 1;STREET 2;CITY;STATE;ZIP;DATE (Submitted);CHG OF COMMITTEE NAME;CHG OF ADDRESS;5. COMMITTEE TYPE;5. FEC CANDIDATE ID NUMBER;5. CANDIDATE NAME;5. CAN/OFFICE ;5. CAN/STATE;5. CAN/DIST;5. PARTY CODE;5. PARTY TYPE;6. FEC COMMITTEE ID NUMBER;6. COMMITTEE NAME (Affiliated);6. STREET 1;6. STREET 2;6. CITY;6. STATE;6. ZIP;6. RELATIONSHIP (w/ Above Cmte);6. ORGANIZATION TYPE;7. IND/NAME (Custodian Name);7. STREET 1;7. STREET 2;7. CITY;7. STATE;7. ZIP;7. TITLE;7. TELEPHONE;8. IND/NAME (Treasurer);8. STREET 1;8. STREET 2;8. CITY;8. STATE;8. ZIP;8. TITLE;8. TELEPHONE;8. IND/NAME (Designated Agent);8. STREET 1;8. STREET 2;8. CITY;8. STATE;8. ZIP;8. TITLE;8. TELEPHONE;9. IND/NAME (Bank/Depository);9. STREET 1;9. STREET 2;9. CITY;9. STATE;9. ZIP;NAME/TREASURER (as signed);DATE (Signed);COMMITTEE EMAIL;COMMITTEE WEB URL;COMMITTEE FAX NUMBER;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
1
|
+
F1;FORM TYPE;FILER FEC CMTE ID ;COMMITTEE NAME;STREET 1;STREET 2;CITY;STATE;ZIP;DATE (Submitted);CHG OF COMMITTEE NAME;CHG OF ADDRESS;5. COMMITTEE TYPE;5. FEC CANDIDATE ID NUMBER;5. CANDIDATE NAME;5. CAN/OFFICE ;5. CAN/STATE;5. CAN/DIST;5. PARTY CODE;5. PARTY TYPE;6. FEC COMMITTEE ID NUMBER;6. COMMITTEE NAME (Affiliated);6. STREET 1;6. STREET 2;6. CITY;6. STATE;6. ZIP;6. RELATIONSHIP (w/ Above Cmte);6. ORGANIZATION TYPE;7. IND/NAME (Custodian Name);7. STREET 1;7. STREET 2;7. CITY;7. STATE;7. ZIP;7. TITLE;7. TELEPHONE;8. IND/NAME (Treasurer);8. STREET 1;8. STREET 2;8. CITY;8. STATE;8. ZIP;8. TITLE;8. TELEPHONE;8. IND/NAME (Designated Agent);8. STREET 1;8. STREET 2;8. CITY;8. STATE;8. ZIP;8. TITLE;8. TELEPHONE;9. IND/NAME (Bank/Depository);9. STREET 1;9. STREET 2;9. CITY;9. STATE;9. ZIP;NAME/TREASURER (as signed);DATE (Signed);COMMITTEE EMAIL;COMMITTEE WEB URL;COMMITTEE FAX NUMBER;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
data/lib/defs/6.1.csv
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
HDR;FORM TYPE;FEC File Version;Filing Software Name;Filing Software Version;Report ID;Report Number
|
data/lib/defs/6.2.csv
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
HDR;FORM TYPE;FEC File Version;Filing Software Name;Filing Software Version;Report ID;Report Number
|
data/lib/defs/6.3.csv
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
HDR;FORM TYPE;FEC File Version;Filing Software Name;Filing Software Version;Report ID;Report Number
|
data/lib/defs/6.4.csv
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
HDR;FORM TYPE;FEC File Version;Filing Software Name;Filing Software Version;Report ID;Report Number
|
data/lib/fechell.rb
CHANGED
@@ -148,7 +148,6 @@ class FECHell
|
|
148
148
|
|
149
149
|
def process_line(fec_version,schedule,line)
|
150
150
|
guesses = guess_schedule(fec_version,schedule)
|
151
|
-
|
152
151
|
offsets = @@modules[fec_version][guesses[0]]
|
153
152
|
values = {}
|
154
153
|
index =0
|
@@ -165,17 +164,19 @@ class FECHell
|
|
165
164
|
seperator,header,form_type,elements = peek_format(filename)
|
166
165
|
|
167
166
|
schedules = guess_schedule(header[:fec_version],form_type)
|
167
|
+
|
168
168
|
if schedules.size == 0 then
|
169
169
|
puts "ERROR: #{filename} - type was #{form_type} we found nothing"
|
170
170
|
end
|
171
171
|
offsets = @@modules[header[:fec_version]][schedules[0]]
|
172
|
+
|
172
173
|
begin
|
173
174
|
FasterCSV.open(filename,:col_sep => seperator).each do |line|
|
174
175
|
next if line.nil?
|
175
176
|
next if line.size == 0
|
176
177
|
sch = line[0]
|
177
178
|
|
178
|
-
next unless sch.match('^[
|
179
|
+
next unless sch.match('^[STFH]')
|
179
180
|
|
180
181
|
guesses,values = process_line(header[:fec_version],sch,line)
|
181
182
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: offensivepolitics-fechell
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Holt
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-06-18 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|