Skip to content

Instantly share code, notes, and snippets.

View jbothma's full-sized avatar

JD Bothma jbothma

View GitHub Profile
# python scrape_wikipedia.py countries.json intros flags
#
# countries.json is countries search facet.
import requests
from lxml import html
import json
from sys import argv
import re
from normality.cleaning import collapse_spaces
This file has been truncated, but you can view the full file.
{"countries":{"us":{"positions":{"plural-3dd261998008c07e480fd7b0c70d73321d64dd20":{"id":"plural-3dd261998008c07e480fd7b0c70d73321d64dd20","name":"Member of the New Jersey Senate","categories":[],"topics":[],"counts":{"total":52,"current":40,"ended":12,"unknown":0}},"Q13218630":{"id":"Q13218630","name":"United States representative","categories":[],"topics":[],"counts":{"total":1200,"current":426,"ended":356,"unknown":418}},"plural-7522a42ade1387949ba0195e68636df4f7f010b0":{"id":"plural-7522a42ade1387949ba0195e68636df4f7f010b0","name":"Governor of Nebraska","categories":[],"topics":[],"counts":{"total":1,"current":0,"ended":1,"unknown":0}},"us-congress-d50d35cd1e6958979e846398314ffa63f0b6760c":{"id":"us-congress-d50d35cd1e6958979e846398314ffa63f0b6760c","name":"United States senator","categories":[],"topics":[],"counts":{"total":122,"current":100,"ended":22,"unknown":0}},"plural-8c7da9224053deecd023a2962fd131393e6220fd":{"id":"plural-8c7da9224053deecd023a2962fd131393e6220fd","name":"Member of the California S
{
"ocid": "ocds-0E7232F7-67EC-42BD-B081-3370171F20B7",
"id": "ocds-0E7232F7-67EC-42BD-B081-3370171F20B7-2022-03-30 13:40:05.8245389",
"date": "2022-03-30T13:40:05",
"initiationType": "tender",
"tender": {
"id": "3622",
"title": "LMN 03/2021",
"status": "active",
"mainProcurementCategory": "Administrative and support activities",
This file has been truncated, but you can view the full file.
{
"countries": {
"af": {
"positions": {
"us-cia-b1efcaa124e747b3612a9e4191f58ecef8d4f0e2": {
"position_name": "Deputy Prime Minister",
"counts": {
"total": 3,
"current": 3,
"ended": 0,
@jbothma
jbothma / spec.json
Created July 10, 2023 07:48
grouped horizonal bar chart
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"description": "A basic grouped bar chart example.",
"width": 300,
"height": 240,
"padding": 5,
"data": [
{
"name": "table",
"values": [

API data practice tasks

This task will give you practice

  • making sense of an unfamiliar API using its documentation
  • handling, transforming and combining data, and coming up with data structures that enable you to present it easily
  • dealing with interdependent API responses that complete in an arbitrary order, and ideally presenting progressively more information to the user as more data becomes available

Focus on logic and clean understandable code rather than visual design.

@jbothma
jbothma / gist:9cb2fcd36dd9b34d10b55d58c8b55aa5
Created May 12, 2023 13:08
Common and varied needs when capturing and presenting fiscal data
Every country probably has its own chart of accounts.
Most of the south african chart doesn't fit in the open fiscal data package standard.
Sometimes you want to impose an ordering on items in a summary. Often the account numbering isn't the correct ordering for long. On muni money we captured that ordering alongside the codes and dimensions.
https://docs.google.com/presentation/d/1tWw1N-LB6FYrHfXs9jM0P0x8ajMQgk53ESMCCpbSaAE/edit?usp=sharing
@jbothma
jbothma / data-model.json
Last active March 6, 2021 12:43
Asylum Assist form data model
[
{
"question_id": "surname",
"answer": [
{
"language": "en",
"value": "Bothma"
},
{
"language": "fr",
@jbothma
jbothma / query.sql
Last active May 1, 2020 08:54
Populate Cargografias template from django-popolo SQL
select p.family_name as "Apellido",
p.given_name as "Nombre",
p.gender as "sexo",
'' as "cargoTipo",
'' as "cargoClase",
m.role as "cargoNominal",
o.name as "Organizacion",
'' as "parentOrg",
'' as "duracionCargo",
a.name as territorio,