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
# script reviews a simplified version of INFORM index data | |
# and harmonizes natural hazards, vulnerability, and coping capacity | |
# then normalizes with population from 2023 | |
import pandas as pd | |
file_path = 'INFORM.xlsx' | |
xls = pd.ExcelFile(file_path) | |
ranks_df = pd.read_excel(xls, 'ranks') |
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
# Given the paginated results, this script can take a few minutes to run. Be patient! | |
import requests | |
import csv | |
base_url = "https://goadmin.ifrc.org/api/v2/ops-learning/" | |
def fetch_data(url): | |
""" | |
Fetches data from the URL passed into it. |
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
#!/usr/bin/env python3 | |
import requests | |
iso2_codes = [ | |
"AF", "AX", "AL", "DZ", "AS", "AD", "AO", "AI", "AQ", "AG", "AR", "AM", "AW", "AU", "AT", "AZ", | |
"BS", "BH", "BD", "BB", "BY", "BE", "BZ", "BJ", "BM", "BT", "BO", "BQ", "BA", "BW", "BV", "BR", | |
"IO", "BN", "BG", "BF", "BI", "CV", "KH", "CM", "CA", "KY", "CF", "TD", "CL", "CN", "CX", "CC", | |
"CO", "KM", "CD", "CG", "CK", "CR", "HR", "CU", "CW", "CY", "CZ", "DK", "DJ", "DM", "DO", "EC", | |
"EG", "SV", "GQ", "ER", "EE", "SZ", "ET", "FK", "FO", "FJ", "FI", "FR", "GF", "PF", "TF", "GA", |
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
import math | |
import csv | |
# script requires requests library | |
# prompt user in console to auto pip install it | |
try: | |
import requests | |
except ImportError as e: | |
response = input("The required module 'requests' is not installed. Would you like to install it now? (yes/no): ") | |
if response.lower() in ['yes', 'y']: |
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
#!/usr/bin/env python3 | |
import csv | |
import requests | |
def flatten_dict(d, parent_key='', sep='_'): | |
""" | |
recursively flattens a nested dictionary to handle GO API data structure. | |
function takes a dictionary that may contain nested dictionaries |
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
const width = 750; | |
const height = 750; | |
const config = { | |
speed: 0.01, | |
verticalTilt: -12, | |
horizontalTilt: 0 | |
}; | |
let locations = []; | |
const svg = d3.select('svg').attr('width', width).attr('height', height); | |
const markerGroup = svg.append('g'); |
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
import csv | |
import pandas as pd | |
from geopy.geocoders import OpenCage | |
# insert your OpenCage API key | |
geocoder = OpenCage('<YOUR_API_KEY_HERE>') | |
# load locations with pandas | |
location_data = 'largest_cities_coordinates.csv' | |
data = pd.read_csv(location_data) |
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
<svg viewBox="100 0 650 650" preserveAspectRatio="none"></svg> | |
<script src="https://d3js.org/d3.v4.min.js"></script> | |
<script src="https://d3js.org/topojson.v1.min.js"></script> | |
<script> | |
const width = 750; | |
const height = 750; | |
const config = { | |
speed: 0.01, | |
verticalTilt: -12, | |
horizontalTilt: 0 |
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
""" | |
Update the event ID and insert your token (leaving quotes around the token code). | |
Save this script in a specific folder where you want the CSV that it generates to also be saved. | |
Note that you will need to update the tags_list values when new profile types are added to RRMS. | |
""" | |
import requests | |
import pandas | |
import csv |
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
#!/usr/bin/env python3 | |
import googlemaps | |
import pandas as pd | |
import csv | |
# save this script in the same folder as your CSV file, then update the name of the file below | |
location_data = 'file_name_here.csv' | |
data = pd.read_csv(location_data) |