-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.py
57 lines (39 loc) · 1.39 KB
/
update.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from csv import writer
from datetime import datetime
from scripts.config import PATHS
from scripts.dt_table import live_dt_table_pipeline
from scripts.idrc_per_capita import export_summary_cost_data, update_refugee_cost_data
from scripts.oda import idrc_as_share, idrc_constant_wide, idrc_oda_chart, update_oda
from scripts.unhcr_data import update_ukraine_hcr_data
def last_updated():
"""Appends the date of last run to a csv"""
with open(PATHS.output / "updates.csv", "a+", newline="") as write_obj:
# Create a writer object from csv module
csv_writer = writer(write_obj)
# Add contents of list as last row in the csv file
csv_writer.writerow([datetime.today()])
def update_daily():
"""Charts to update every week"""
# Update Ukraine refugees data
update_ukraine_hcr_data()
# Update IDRC estimates charts
idrc_as_share()
# Update IDRC ODA chart
idrc_oda_chart()
# Update IDRC constant chart
idrc_constant_wide()
# Update donor tracker table
live_dt_table_pipeline()
# Export summary cost data
export_summary_cost_data()
def update_weekly():
"""Charts to update every week"""
# update historical refugee estimates
update_refugee_cost_data()
# update monthly oda
update_oda()
# Update last updated date
last_updated()
if __name__ == "__main__":
update_daily()
update_weekly()