forked from datasets/country-codes
-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Peter edited this page Aug 3, 2018
·
2 revisions
Welcome to the country-codes wiki!
Check the query discussion at https://stackoverflow.com/questions/51673685
Prepare for issue 53
https://github.com/datasets/country-codes/issues/53
- prepare https://github.com/datasets-br/sql-unifier
- lix: query Wikidata and get CSV
- check and eliminate lines from lix
- rebuild country-codes CSV
- 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;