12 lines
503 B
Shell
12 lines
503 B
Shell
#!/bin/bash
|
|
|
|
set -e -u -o pipefail
|
|
|
|
# - download
|
|
# - filter out comments
|
|
# - select columns from TSV
|
|
# - format JSON
|
|
curl -s https://download.geonames.org/export/dump/countryInfo.txt \
|
|
| grep -v '^#' \
|
|
| cut -f1,2,5,17 \
|
|
| sed -e 's%\([^\t]\+\)\t\([^\t]\+\)\t\([^\t]\+\)\t\([^\t]\+\)%{"pid": "geodata:\4", "display_label": "\3", "attributes": [{"predicate": "obo:GEO_000000023", "value": "\1"}, {"predicate": "obo:GEO_000000022", "value": "\2"}, {"predicate": "dcterms:title", "value": "\3"}]}%g'
|