This repository has been archived by the owner on Nov 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
downloads contractor contribs and tries to match results to contracto…
…r list
- Loading branch information
Showing
3 changed files
with
66 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,7 @@ nj_campfin_scraped.json | |
out.json | ||
temp_filing.pdf | ||
build/ | ||
dist/ | ||
dist/ | ||
*.csv | ||
*.json | ||
*.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import csv | ||
from fuzzywuzzy import fuzz | ||
|
||
results = [] | ||
|
||
with open('/Users/208301/aggregate_property_contribs.csv', 'r') as f: | ||
with open('/Users/208301/property_contracts.csv', 'r') as g: | ||
contracts = [] | ||
contribs_reader = csv.reader(f) | ||
contracts_reader = csv.reader(g) | ||
next(contracts_reader) | ||
for row in contracts_reader: | ||
contracts.append(row) | ||
|
||
next(contribs_reader) | ||
for row in contribs_reader: | ||
best_match = '' | ||
best_match_amount = -1 | ||
best_score = 0 | ||
for contract in contracts: | ||
score = fuzz.ratio(row[0], contract[0]) | ||
if score > best_score and score > 75: | ||
best_match = contract[0] | ||
best_score = score | ||
best_match_amount = contract[4] | ||
|
||
new_row = row + [best_match, best_match_amount] | ||
results.append(new_row) | ||
|
||
with open('/Users/208301/aggregate_property_contribs_matched.csv', 'w') as h: | ||
writer = csv.writer(h) | ||
writer.writerows(results) |