-
-
Notifications
You must be signed in to change notification settings - Fork 21
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
b40cd5b
commit 92b8b86
Showing
12 changed files
with
523 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
206 changes: 206 additions & 0 deletions
206
etl/steps/data/garden/terrorism/2023-07-20/global_terrorism_database.countries.json
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,206 @@ | ||
{ | ||
"Afghanistan": "Afghanistan", | ||
"Albania": "Albania", | ||
"Algeria": "Algeria", | ||
"Andorra": "Andorra", | ||
"Angola": "Angola", | ||
"Antigua and Barbuda": "Antigua and Barbuda", | ||
"Argentina": "Argentina", | ||
"Armenia": "Armenia", | ||
"Australia": "Australia", | ||
"Austria": "Austria", | ||
"Azerbaijan": "Azerbaijan", | ||
"Bahamas": "Bahamas", | ||
"Bahrain": "Bahrain", | ||
"Bangladesh": "Bangladesh", | ||
"Barbados": "Barbados", | ||
"Belarus": "Belarus", | ||
"Belgium": "Belgium", | ||
"Belize": "Belize", | ||
"Benin": "Benin", | ||
"Bhutan": "Bhutan", | ||
"Bolivia": "Bolivia", | ||
"Botswana": "Botswana", | ||
"Brazil": "Brazil", | ||
"Brunei": "Brunei", | ||
"Bulgaria": "Bulgaria", | ||
"Burkina Faso": "Burkina Faso", | ||
"Burundi": "Burundi", | ||
"Cambodia": "Cambodia", | ||
"Cameroon": "Cameroon", | ||
"Canada": "Canada", | ||
"Central African Republic": "Central African Republic", | ||
"Chad": "Chad", | ||
"Chile": "Chile", | ||
"China": "China", | ||
"Colombia": "Colombia", | ||
"Comoros": "Comoros", | ||
"Costa Rica": "Costa Rica", | ||
"Croatia": "Croatia", | ||
"Cuba": "Cuba", | ||
"Cyprus": "Cyprus", | ||
"Czech Republic": "Czechia", | ||
"Czechoslovakia": "Czechoslovakia", | ||
"Democratic Republic of the Congo": "Democratic Republic of Congo", | ||
"Denmark": "Denmark", | ||
"Djibouti": "Djibouti", | ||
"Dominica": "Dominica", | ||
"Dominican Republic": "Dominican Republic", | ||
"East Timor": "East Timor", | ||
"Ecuador": "Ecuador", | ||
"Egypt": "Egypt", | ||
"El Salvador": "El Salvador", | ||
"Equatorial Guinea": "Equatorial Guinea", | ||
"Eritrea": "Eritrea", | ||
"Estonia": "Estonia", | ||
"Ethiopia": "Ethiopia", | ||
"Falkland Islands": "Falkland Islands", | ||
"Fiji": "Fiji", | ||
"Finland": "Finland", | ||
"France": "France", | ||
"French Guiana": "French Guiana", | ||
"French Polynesia": "French Polynesia", | ||
"Gabon": "Gabon", | ||
"Gambia": "Gambia", | ||
"Georgia": "Georgia", | ||
"Germany": "Germany", | ||
"Ghana": "Ghana", | ||
"Greece": "Greece", | ||
"Grenada": "Grenada", | ||
"Guadeloupe": "Guadeloupe", | ||
"Guatemala": "Guatemala", | ||
"Guinea": "Guinea", | ||
"Guinea-Bissau": "Guinea-Bissau", | ||
"Guyana": "Guyana", | ||
"Haiti": "Haiti", | ||
"Honduras": "Honduras", | ||
"Hong Kong": "Hong Kong", | ||
"Hungary": "Hungary", | ||
"Iceland": "Iceland", | ||
"India": "India", | ||
"Indonesia": "Indonesia", | ||
"Iran": "Iran", | ||
"Iraq": "Iraq", | ||
"Ireland": "Ireland", | ||
"Israel": "Israel", | ||
"Italy": "Italy", | ||
"Ivory Coast": "Cote d'Ivoire", | ||
"Jamaica": "Jamaica", | ||
"Japan": "Japan", | ||
"Jordan": "Jordan", | ||
"Kazakhstan": "Kazakhstan", | ||
"Kenya": "Kenya", | ||
"Kosovo": "Kosovo", | ||
"Kuwait": "Kuwait", | ||
"Kyrgyzstan": "Kyrgyzstan", | ||
"Laos": "Laos", | ||
"Latvia": "Latvia", | ||
"Lebanon": "Lebanon", | ||
"Lesotho": "Lesotho", | ||
"Liberia": "Liberia", | ||
"Libya": "Libya", | ||
"Lithuania": "Lithuania", | ||
"Luxembourg": "Luxembourg", | ||
"Macau": "Macao", | ||
"Macedonia": "North Macedonia", | ||
"Madagascar": "Madagascar", | ||
"Malawi": "Malawi", | ||
"Malaysia": "Malaysia", | ||
"Maldives": "Maldives", | ||
"Mali": "Mali", | ||
"Malta": "Malta", | ||
"Martinique": "Martinique", | ||
"Mauritania": "Mauritania", | ||
"Mauritius": "Mauritius", | ||
"Mexico": "Mexico", | ||
"Moldova": "Moldova", | ||
"Montenegro": "Montenegro", | ||
"Morocco": "Morocco", | ||
"Mozambique": "Mozambique", | ||
"Myanmar": "Myanmar", | ||
"Namibia": "Namibia", | ||
"Nepal": "Nepal", | ||
"Netherlands": "Netherlands", | ||
"New Caledonia": "New Caledonia", | ||
"New Zealand": "New Zealand", | ||
"Nicaragua": "Nicaragua", | ||
"Niger": "Niger", | ||
"Nigeria": "Nigeria", | ||
"North Korea": "North Korea", | ||
"Norway": "Norway", | ||
"Pakistan": "Pakistan", | ||
"Panama": "Panama", | ||
"Papua New Guinea": "Papua New Guinea", | ||
"Paraguay": "Paraguay", | ||
"Peru": "Peru", | ||
"Philippines": "Philippines", | ||
"Poland": "Poland", | ||
"Portugal": "Portugal", | ||
"Qatar": "Qatar", | ||
"Romania": "Romania", | ||
"Russia": "Russia", | ||
"Rwanda": "Rwanda", | ||
"Saudi Arabia": "Saudi Arabia", | ||
"Senegal": "Senegal", | ||
"Serbia": "Serbia", | ||
"Seychelles": "Seychelles", | ||
"Sierra Leone": "Sierra Leone", | ||
"Singapore": "Singapore", | ||
"Slovak Republic": "Slovakia", | ||
"Slovenia": "Slovenia", | ||
"Solomon Islands": "Solomon Islands", | ||
"Somalia": "Somalia", | ||
"South Africa": "South Africa", | ||
"South Korea": "South Korea", | ||
"South Sudan": "South Sudan", | ||
"Soviet Union": "USSR", | ||
"Spain": "Spain", | ||
"Sri Lanka": "Sri Lanka", | ||
"St. Kitts and Nevis": "Saint Kitts and Nevis", | ||
"St. Lucia": "Saint Lucia", | ||
"Sudan": "Sudan", | ||
"Suriname": "Suriname", | ||
"Swaziland": "Eswatini", | ||
"Sweden": "Sweden", | ||
"Switzerland": "Switzerland", | ||
"Syria": "Syria", | ||
"Taiwan": "Taiwan", | ||
"Tajikistan": "Tajikistan", | ||
"Tanzania": "Tanzania", | ||
"Thailand": "Thailand", | ||
"Togo": "Togo", | ||
"Trinidad and Tobago": "Trinidad and Tobago", | ||
"Tunisia": "Tunisia", | ||
"Turkey": "Turkey", | ||
"Turkmenistan": "Turkmenistan", | ||
"Uganda": "Uganda", | ||
"Ukraine": "Ukraine", | ||
"United Arab Emirates": "United Arab Emirates", | ||
"United Kingdom": "United Kingdom", | ||
"United States": "United States", | ||
"Uruguay": "Uruguay", | ||
"Uzbekistan": "Uzbekistan", | ||
"Vanuatu": "Vanuatu", | ||
"Venezuela": "Venezuela", | ||
"Vietnam": "Vietnam", | ||
"Wallis and Futuna": "Wallis and Futuna", | ||
"Western Sahara": "Western Sahara", | ||
"Yemen": "Yemen", | ||
"Yugoslavia": "Yugoslavia", | ||
"Zambia": "Zambia", | ||
"Zimbabwe": "Zimbabwe", | ||
"Bosnia-Herzegovina": "Bosnia and Herzegovina", | ||
"East Germany (GDR)": "East Germany", | ||
"International": "International", | ||
"New Hebrides": "New Hebrides", | ||
"North Yemen": "Yemen Arab Republic", | ||
"People's Republic of the Congo": "People's Republic of the Congo", | ||
"Republic of the Congo": "Republic of the Congo", | ||
"Rhodesia": "Rhodesia", | ||
"Serbia-Montenegro": "Serbia and Montenegro", | ||
"South Yemen": "South Yemen", | ||
"Vatican City": "Vatican", | ||
"West Bank and Gaza Strip": "West Bank and Gaza Strip", | ||
"West Germany (FRG)": "West Germany", | ||
"Zaire": "Zaire" | ||
} |
2 changes: 2 additions & 0 deletions
2
etl/steps/data/garden/terrorism/2023-07-20/global_terrorism_database.excluded_countries.json
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,2 @@ | ||
[ | ||
] |
35 changes: 35 additions & 0 deletions
35
etl/steps/data/garden/terrorism/2023-07-20/global_terrorism_database.meta.yml
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,35 @@ | ||
# (Inherited from meadow, remove if not different.) | ||
all_sources: | ||
- source_testing: &source-testing | ||
name: # Example: Testing Short Citation | ||
published_by: # (if different to short citation). Example: Testing Full Citation | ||
url: # Example: https://url_of_testing_source.com/ | ||
date_accessed: # Example: 2023-01-01 | ||
publication_date: # Example: 2023-01-01 | ||
publication_year: # (if publication_date is not given). Example: 2023 | ||
# description: Source description. | ||
|
||
# (Inherited from meadow, remove if not different.) | ||
dataset: | ||
title: # Example: Testing Dataset Name (Institution, 2023) | ||
# description: Dataset description. | ||
licenses: | ||
- name: # Example: Testing License Name | ||
url: # Example: https://url_of_testing_source.com/license | ||
sources: | ||
- *source-testing | ||
|
||
tables: | ||
global_terrorism_database: | ||
# (Inherited from meadow, remove if not different.) | ||
variables: | ||
# testing_variable: | ||
# title: Testing variable title | ||
# unit: arbitrary units | ||
# short_unit: au | ||
# description: Full description of testing variable. | ||
# sources: | ||
# - *source-testing | ||
# display: | ||
# entityAnnotationsMap: Test annotation | ||
# numDecimalPlaces: 0 |
38 changes: 38 additions & 0 deletions
38
etl/steps/data/garden/terrorism/2023-07-20/global_terrorism_database.py
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,38 @@ | ||
"""Load a meadow dataset and create a garden dataset.""" | ||
|
||
from typing import cast | ||
|
||
from owid.catalog import Dataset, Table | ||
|
||
from etl.data_helpers import geo | ||
from etl.helpers import PathFinder, create_dataset | ||
|
||
# Get paths and naming conventions for current step. | ||
paths = PathFinder(__file__) | ||
|
||
|
||
def run(dest_dir: str) -> None: | ||
# | ||
# Load inputs. | ||
# | ||
# Load meadow dataset. | ||
ds_meadow = cast(Dataset, paths.load_dependency("global_terrorism_database")) | ||
|
||
# Read table from meadow dataset. | ||
tb = ds_meadow["global_terrorism_database"] | ||
|
||
# | ||
# Process data. | ||
# | ||
tb: Table = geo.harmonize_countries( | ||
df=tb, countries_file=paths.country_mapping_path, excluded_countries_file=paths.excluded_countries_path | ||
) | ||
|
||
# | ||
# Save outputs. | ||
# | ||
# Create a new garden dataset with the same metadata as the meadow dataset. | ||
ds_garden = create_dataset(dest_dir, tables=[tb], default_metadata=ds_meadow.metadata) | ||
|
||
# Save changes in the new garden dataset. | ||
ds_garden.save() |
39 changes: 39 additions & 0 deletions
39
etl/steps/data/grapher/terrorism/2023-07-20/global_terrorism_database.py
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,39 @@ | ||
"""Load a garden dataset and create a grapher dataset.""" | ||
|
||
from typing import cast | ||
|
||
from owid.catalog import Dataset | ||
|
||
from etl.helpers import PathFinder, create_dataset, grapher_checks | ||
|
||
# Get paths and naming conventions for current step. | ||
paths = PathFinder(__file__) | ||
|
||
|
||
def run(dest_dir: str) -> None: | ||
# | ||
# Load inputs. | ||
# | ||
# Load garden dataset. | ||
ds_garden = cast(Dataset, paths.load_dependency("global_terrorism_database")) | ||
|
||
# Read table from garden dataset. | ||
tb = ds_garden["global_terrorism_database"] | ||
|
||
# | ||
# Process data. | ||
# | ||
|
||
# | ||
# Save outputs. | ||
# | ||
# Create a new grapher dataset with the same metadata as the garden dataset. | ||
ds_grapher = create_dataset(dest_dir, tables=[tb], default_metadata=ds_garden.metadata) | ||
|
||
# | ||
# Checks. | ||
# | ||
grapher_checks(ds_grapher) | ||
|
||
# Save changes in the new grapher dataset. | ||
ds_grapher.save() |
Oops, something went wrong.