-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4408f50
commit db68929
Showing
2 changed files
with
27 additions
and
1 deletion.
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
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,26 @@ | ||
import csv | ||
from budgetportal.models.government import PublicEntity | ||
|
||
# Open the CSV file | ||
with open("public_entities_descriptions.csv", newline="") as csvfile: | ||
# Create a DictReader object with named columns | ||
csvreader = csv.DictReader(csvfile) | ||
|
||
updated = [] | ||
not_found = [] | ||
for row in csvreader: | ||
public_entities = PublicEntity.objects.filter(name=row['Entity Name']) | ||
if public_entities: | ||
for entity in public_entities: | ||
entity.description = row['Description'] | ||
entity.save() | ||
print(f"Updated description for {entity.name}") | ||
updated.append(entity.name) | ||
else: | ||
print(f"Could not find public entity {row['Entity Name']}") | ||
not_found.append(row['Entity Name']) | ||
|
||
print(f"Updated {len(updated)} public entities") | ||
print(f"Could not find {len(not_found)} public entities") | ||
print("Not found:") | ||
print(not_found) |