Single build output: Earth.db with cumulative CO2 emissions

This commit is contained in:
heyarne 2021-06-11 10:31:08 +02:00
commit a8e558b3d5
2 changed files with 23 additions and 0 deletions

15
default.nix Normal file
View file

@ -0,0 +1,15 @@
{ pkgs ? import <nixpkgs> {} }:
let
name = "earth";
builder = ./importers/owid.sh;
src = ./sources/cumulative_co2_emissions.csv;
csvsToSqlite = pkgs.csvs-to-sqlite;
in
pkgs.stdenv.mkDerivation {
name = "${name}.db";
inherit src;
inherit builder;
inherit csvsToSqlite;
}

8
importers/owid.sh Normal file
View file

@ -0,0 +1,8 @@
#!/usr/bin/env bash
${csvsToSqlite}/bin/csvs-to-sqlite \
--shape 'Entity:entity(text),Code:code(text),Year:year(integer),Cumulative CO2 emissions:cumulative_co2_emissions(real)' \
--index entity \
--index code \
--index year \
--replace-tables \
$src $out