Giter VIP home page Giter VIP logo

myndigheterna's Introduction

A database of public bodies (or organizations):

Government-run or controlled organizations or entities which may or may not have distinct corporate existence

Examples are:

  • Government Ministries or Departments
  • State-run Health organizations
  • Police and fire departments

Data

Data is stored in CSVs partitioned by country or region (e.g. EU). Directories are named by ISO code.

Contribute Data

Please just add a CSV file and submit a pull request or open an issue.

The set of fields required in the CSV file can be seen in the field list on: http://data.okfn.org/community/okfn/publicbodies (if you like JSON you look directly at the datapackage.json file in this repo - you can also check out the existing data in data/).

For Developers of the Website

The website is a node webapp. To get it running:

  1. Install node and npm (>= 0.8)

  2. Get the code

     git clone https://github.com/okfn/publicbodies
    
  3. Install the dependencies (make sure you are in the publicbodies directory)

     npm install .
    
  4. Run the webapp:

     node index.js
    

The list of outstanding issues is at: https://github.com/okfn/publicbodies/issues


Original Preparation

Details of the automated data extraction to build the original database.

Data sources:

Building the SQLite DB

Schema:

title
abbr
key
slug
category
parent
parent_key
description
url
jurisdiction
jurisdiction_code
source
source_url
source_description
address
contact
email
tags
created_at
updated_at

SQL

ALTER TABLE froide_de ADD COLUMN source; 
ALTER TABLE froide_de ADD COLUMN source_description;
ALTER TABLE froide_de ADD COLUMN source_url;
UPDATE froide_de SET source = 'FragDenStaat / Bund Online';
UPDATE froide_de SET source_url = 'https://fragdenstaat.de/hilfe/';
UPDATE froide_de SET source_description = 'Federal-level agencies of the German government';

ALTER TABLE froide_de ADD COLUMN jurisdiction;
ALTER TABLE froide_de ADD COLUMN jurisdiction_code;
UPDATE froide_de SET jurisdiction = 'Germany';
UPDATE froide_de SET jurisdiction_code = 'DE';

ALTER TABLE ateu_en ADD COLUMN source; 
ALTER TABLE ateu_en ADD COLUMN source_description;
ALTER TABLE ateu_en ADD COLUMN source_url;
UPDATE ateu_en SET source = 'Ask the EU (AccessInfo)';
UPDATE ateu_en SET source_url = 'http://www.asktheeu.org/de/help/api';
UPDATE ateu_en SET source_description = 'European-level FoI request tracker';

ALTER TABLE ateu_en ADD COLUMN jurisdiction;
ALTER TABLE ateu_en ADD COLUMN jurisdiction_code;
UPDATE ateu_en SET jurisdiction = 'European Union';
UPDATE ateu_en SET jurisdiction_code = 'EU';

ALTER TABLE wdtk_gb ADD COLUMN source; 
ALTER TABLE wdtk_gb ADD COLUMN source_description;
ALTER TABLE wdtk_gb ADD COLUMN source_url;
UPDATE wdtk_gb SET source = 'What do they know? (MySociety)';
UPDATE wdtk_gb SET source_url = 'http://www.whatdotheyknow.com/help/api';
UPDATE wdtk_gb SET source_description = 'UK FoI site';

ALTER TABLE wdtk_gb ADD COLUMN jurisdiction;
ALTER TABLE wdtk_gb ADD COLUMN jurisdiction_code;
UPDATE wdtk_gb SET jurisdiction = 'United Kingdom';
UPDATE wdtk_gb SET jurisdiction_code = 'GB';


CREATE TABLE entity (
  title TEXT,
  abbr TEXT,
  key TEXT,
  slug TEXT,
  category TEXT,
  parent TEXT,
  parent_key TEXT,
  description TEXT,
  url TEXT,
  jurisdiction TEXT,
  jurisdiction_code TEXT,
  source TEXT,
  source_url TEXT,
  source_description TEXT,
  address TEXT,
  contact TEXT,
  email TEXT,
  tags TEXT,
  created_at TEXT,
  updated_at TEXT);

DELETE FROM entity;
INSERT INTO entity 
  (title, category, parent, description, url, jurisdiction, 
   jurisdiction_code, source, source_url, source_description, 
   address, contact, email, tags) 
  SELECT title, class, parent, description, url, jurisdiction, 
    jurisdiction_code, source, source_url, source_description, 
    address, contacts AS contact, email, tags FROM froide_de; 

INSERT INTO entity
  (title, abbr, slug, url, jurisdiction, jurisdiction_code, source, 
   source_url, source_description, tags, created_at, updated_at) 
  SELECT Name AS title, `Short name` AS abbr, `URL Name` AS slug, 
     `Home page` AS url, jurisdiction, jurisdiction_code, source, 
     source_url, source_description, Tags as tags, `Created at` 
     AS created_at, `Updated at` AS updated_at FROM wdtk_gb; 

INSERT INTO entity
  (title, abbr, slug, url, jurisdiction, jurisdiction_code, source, 
   source_url, source_description, tags, created_at, updated_at) 
  SELECT Name AS title, `Short name` AS abbr, `URL Name` AS slug, 
     `Home page` AS url, jurisdiction, jurisdiction_code, source, 
     source_url, source_description, Tags as tags, `Created at` 
     AS created_at, `Updated at` AS updated_at FROM ateu_en; 


CREATE TABLE alias (alias TEXT, key TEXT);
DELETE FROM alias;
INSERT INTO alias (alias, key) SELECT abbr AS alias, key AS key 
  FROM entity WHERE abbr IS NOT NULL AND LENGTH(abbr);
INSERT INTO alias (alias, key) SELECT (SELECT ateu.Name AS alias FROM 
ateu_de ateu WHERE ateu.`Home page` = ent.url) AS alias, ent.key AS key
FROM entity ent; 
INSERT INTO alias (alias, key) SELECT (SELECT ateu.Name AS alias FROM 
ateu_de ateu WHERE ateu.`Short name` = ent.abbr) AS alias, ent.key AS key
FROM entity ent; 
INSERT INTO alias (alias, key) SELECT (SELECT ateu.Name AS alias FROM 
ateu_fr ateu WHERE ateu.`Home page` = ent.url) AS alias, ent.key AS key
FROM entity ent; 
INSERT INTO alias (alias, key) SELECT (SELECT ateu.Name AS alias FROM 
ateu_fr ateu WHERE ateu.`Short name` = ent.abbr) AS alias, ent.key AS key
FROM entity ent; 
INSERT INTO alias (alias, key) SELECT (SELECT ateu.Name AS alias FROM 
ateu_es ateu WHERE ateu.`Home page` = ent.url) AS alias, ent.key AS key
FROM entity ent; 
INSERT INTO alias (alias, key) SELECT (SELECT ateu.Name AS alias FROM 
ateu_es ateu WHERE ateu.`Short name` = ent.abbr) AS alias, ent.key AS key
FROM entity ent; 
DELETE FROM alias WHERE alias IS NULL;


CREATE TABLE types (
  name TEXT,
  db_url TEXT,
  entity_table TEXT,
  entity_key TEXT,
  alias_table TEXT,
  alias_text TEXT,
  alias_key TEXT
  );

INSERT INTO types (name, db_url, entity_table,
  entity_key, alias_table, alias_text, alias_key) VALUES
  ('bodies', 'http://localhost:5000/pudo/publicbody', 
  'entity', 'key', 'alias', 'alias', 'key');

SQL to extract data from sqlite to CSV

.output entities.csv
.mode csv
.headers ON

SELECT * FROM entity;

myndigheterna's People

Contributors

rufuspollock avatar wombleton avatar augusto-herrmann avatar hannesgassert avatar pudo avatar okfngr avatar todrobbins avatar andylolz avatar

Stargazers

 avatar

Watchers

Robin Harms Oredsson avatar James Cloos avatar Mattias Axell avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.