Skip to content

Commit

Permalink
committee_list merged result added
Browse files Browse the repository at this point in the history
  • Loading branch information
majorika committed Nov 12, 2014
1 parent f542d28 commit 87f1c21
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions committee_list/crawlers/committee_list/parser.py
Expand Up @@ -60,14 +60,26 @@ def parse(directory, filename, rng=None):
crawl(url % p, directory, p)

index = 0
for p in committee_codes:
n = ('%s' % filename).replace(".csv",'_%s.csv' % committee_names[index])
with open(n, 'wa') as f:
inf = '%s/%s.html' % (directory, p)
f.write('"title","political party","name","phone","email"\n')
f.write('\n'.join(get_committee_list(inf, x2)).encode('utf-8'))
f.write('\n')
print 'parsed %s' % inf
print 'Results written to ' + n

index = index + 1
with open(filename, 'wa') as merged:
merged.write('"committe","title","political party","name","phone","email"\n')

for p in committee_codes:
n = ('%s' % filename).replace(".csv",'_%s.csv' % committee_names[index])
with open(n, 'wa') as f:
inf = '%s/%s.html' % (directory, p)
committee_list = get_committee_list(inf, x2)

merged.write((('"%s",') % committee_names[index]).encode('utf-8'))
merged.write((('\n"%s",') % committee_names[index]).join(committee_list).encode('utf-8'))
merged.write('\n')

f.write('"title","political party","name","phone","email"\n')
f.write('\n'.join(committee_list).encode('utf-8'))
f.write('\n')
print 'parsed %s' % inf
print 'Results written to ' + n

index = index + 1

merged.write('\n')
print 'Result written to ' + filename

0 comments on commit 87f1c21

Please sign in to comment.