Skip to content

Commit

Permalink
Public entity descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmwatson committed May 13, 2024
1 parent 4408f50 commit db68929
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion import_plublic_entities_expenditure.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def make_financial_year(year):
count = 0
# Loop through each row in the CSV file
for row in csvreader:
if count >= 100000:
if count >= 1000000:
break

# Increment the counter
Expand Down
26 changes: 26 additions & 0 deletions import_public_entities_descriptions.py
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)

0 comments on commit db68929

Please sign in to comment.