Skip to content
Peter edited this page Aug 3, 2018 · 2 revisions

Welcome to the country-codes wiki!

NEW

Check the query discussion at https://stackoverflow.com/questions/51673685


OLD

Prepare for issue 53

https://github.com/datasets/country-codes/issues/53

  1. prepare https://github.com/datasets-br/sql-unifier
  2. lix: query Wikidata and get CSV
  3. check and eliminate lines from lix
  4. rebuild country-codes CSV
  5. change datapack
          ,{
            "name": "wdId",
            "description": "Wikidata concept (semantic) identifier",
            "urlTpl": "https://www.wikidata.org/wiki/{value}",
            "title":"Wikidata ID",
            "type": "string"
          }
-- create table lix (item text, code text); COPY lix FROM '/tmp/country-wd.csv' CSV HEAD;

-- Check and eliminate
SELECT *, (replace(item,'Q',''))::int as x from lix where code IN (select code from lix  group by 1 having count(*)>1) order by 2,3 desc;

-- Rebuild
COPY (
  SELECT  c.*, w.item as "wdId" 
  FROM dataset.vw_country_codes c LEFT JOIN lix w 
    ON w.code=c.iso3166_1_alpha_2 AND w.code IS NOT NULL 
       AND  w.item NOT IN ('Q165783', 'Q2895', 'Q1249802', 'Q29999', 'Q407199', 'Q838261')
) TO '/tmp/lixBom.csv' CSV HEADER;
Clone this wiki locally