Skip to content

Instantly share code, notes, and snippets.

View rufuspollock's full-sized avatar
🌎
Nothing, nowhere and all of it

Rufus Pollock rufuspollock

🌎
Nothing, nowhere and all of it
View GitHub Profile
@rufuspollock
rufuspollock / README.md
Created March 6, 2014 19:54
Hackney Spending Cleanup - README is empty

README is empty

@rufuspollock
rufuspollock / README.md
Created March 9, 2014 18:58
Global Fossil Fuel CO2 Emissions 1751-Present - README is empty

README is empty

@rufuspollock
rufuspollock / scrape-ckan-extensions-on-github.py
Created May 4, 2014 21:49
Scrape CKAN Extensions on Github
'''Run this script and it will export a list of all CKAN extensions on github
(guessed by repo name containing ckanext) to json and csv files in in this directory
'''
import urllib
import json
import csv
jsonfp = 'extensions-gh.json'
csvfp = 'extensions-gh.csv'

This is a short introduction to how to administer an Open Data Census.

Note: it assumes that a census instance has been booted for you (and is not about the technical side of deploying a census instance)

[toc]

Overview of How a Census is Structured

A Census is a survey built around 4 axes:

@rufuspollock
rufuspollock / home.md
Created May 21, 2014 16:50
meta.census.okfn.org - home page

[notitle] [fullwidth]

Get your local open data census here!
Local data is often the most relevant to citizens on a daily basis - from rubbish collection times to local tax rates.
At the moment it’s hard to know what local open data is available.

@rufuspollock
rufuspollock / humanitarian-datastore-data-api-examples.md
Last active August 29, 2015 14:03
Humanitarian dataset example queries

HDX Common Humanitarian Dataset data into CKAN instance (we used datahub.io for convenience).

http://datahub.io/dataset/hdx-common-humanitarian-dataset

We've loaded (indicator) value table and indicator table separately in the CKAN DataStore (we have not bothered loading dataset table for the present) and we've also created a python script to automate this (which can also serve as an example of how to work with CKAN API).

Setting this up was pretty fast (most of the work was actually tidying up the data and then making some scripts to make this repeatable and testable).

@rufuspollock
rufuspollock / gist:ca4ac7d2511ee41237b9
Created November 9, 2014 21:37
CKAN DataStore SQL API from Javascript
// replace this with your CKAN website
var ckanSite = 'http://datahub.io'
var sql = 'Your SQL goes here';
// =================
// Using jQuery only
// =================
var data = encodeURIComponent(JSON.stringify({sql: sql}));
We can make this file beautiful and searchable if this error is corrected: It looks like row 4 should actually have 17 columns, instead of 10. in line 3.
year,admin1,admin2,admin3,admin4,admin5,admin6,func1,func2,econ1,econ2,fin_source,exp_type,transfer,approved,adjusted,executed
2009,Central,101 Parliament,0101 Parliament,,,010 Central apparatus (office) of ministries and other administrative authorities,01 General purpose state services,01.01 Legislative authorities,111 Remuneration of work,111.00 Remuneration of work,Base component,Personnel,Excluding transfers,30269300,30269300,27849186
2009,Central,101 Parliament,0101 Parliament,,,010 Central apparatus (office) of ministries and other administrative authorities,01 General purpose state services,01.01 Legislative authorities,112 Mandatory state social insurance premiums,112.00 Mandatory state social insurance premiums,Base component,Personnel,Excluding transfers,5564000,5564000,5401021
2009,Central,101 Parliament,0101 Parliament,,,010 Central apparatus (office) of ministries and other administrative authorities,01 General purpose state services,01.01 Legislative authorities,113 Payment for goods and servic
@rufuspollock
rufuspollock / ckan-data-preview-sample-dataset
Created October 9, 2011 11:23
CKAN Data Preview Sample Dataset
import ckanclient
base_location = 'http://localhost:5000/api'
api_key = 'tester'
client = ckanclient.CkanClient(base_location, api_key)
pkg = dict(
name='test-ckanext-datapreview',
title='Test CKANext Data Preview',
resources=[
dict(
@rufuspollock
rufuspollock / userstories.py
Created November 7, 2011 19:05
Get user stories out a spreadsheet and into mediawiki syntax
# Get user stories out a spreadsheet and into mediawiki syntax
#
# Designed for this set here
# https://docs.google.com/spreadsheet/ccc?key=0Aon3JiuouxLUdFhMVEVFWXhxWXRKaU04LUF2ZTVsTVE&hl=en_GB#gid=0
# Pass it link to gdocs csv as argument on command line
# E.g.
#
# python userstories.py "https://docs.google.com/spreadsheet/pub?hl=en_GB&hl=en_GB&key=0Aon3JiuouxLUdFhMVEVFWXhxWXRKaU04LUF2ZTVsTVE&single=true&gid=0&output=csv"
#
import urllib