CoCalc
Shareddatahub / datahub.ipynbOpen in CoCalc
Author: Harald Schilly
Views : 2

https://datahub.io

Python 3 (Ubuntu Linux)

from datapackage import Package
package = Package('https://datahub.io/core/world-cities/datapackage.json')
# print list of all resources: print(package.resource_names)
['validation_report', 'world-cities_csv', 'world-cities_json', 'world-cities_zip', 'world-cities_csv_preview', 'world-cities']
def show(data): for no, line in enumerate(data): print(line) if no > 100: return
# print processed tabular data (if exists any) for resource in package.resources: if resource.descriptor['datahub']['type'] == 'derived/csv': show(resource.read())
['les Escaldes', 'Andorra', 'Escaldes-Engordany', 3040051] ['Andorra la Vella', 'Andorra', 'Andorra la Vella', 3041563] ['Umm al Qaywayn', 'United Arab Emirates', 'Umm al Qaywayn', 290594] ['Ras al-Khaimah', 'United Arab Emirates', 'Raʼs al Khaymah', 291074] ['Khawr Fakkān', 'United Arab Emirates', 'Ash Shāriqah', 291696] ['Dubai', 'United Arab Emirates', 'Dubai', 292223] ['Dibba Al-Fujairah', 'United Arab Emirates', 'Al Fujayrah', 292231] ['Dibba Al-Hisn', 'United Arab Emirates', 'Al Fujayrah', 292239] ['Sharjah', 'United Arab Emirates', 'Ash Shāriqah', 292672] ['Ar Ruways', 'United Arab Emirates', 'Abu Dhabi', 292688] ['Al Fujayrah', 'United Arab Emirates', 'Al Fujayrah', 292878] ['Al Ain', 'United Arab Emirates', 'Abu Dhabi', 292913] ['Ajman', 'United Arab Emirates', 'Ajman', 292932] ['Adh Dhayd', 'United Arab Emirates', 'Ash Shāriqah', 292953] ['Abu Dhabi', 'United Arab Emirates', 'Abu Dhabi', 292968] ['Zaranj', 'Afghanistan', 'Nīmrūz', 1120985] ['Taloqan', 'Afghanistan', 'Takhār', 1123004] ['Shīnḏanḏ', 'Afghanistan', 'Herat', 1125155] ['Shibirghān', 'Afghanistan', 'Jowzjān', 1125444] ['Shahrak', 'Afghanistan', 'Ghowr', 1125896] ['Sar-e Pul', 'Afghanistan', 'Sar-e Pol', 1127110] ['Sang-e Chārak', 'Afghanistan', 'Sar-e Pol', 1127628] ['Aībak', 'Afghanistan', 'Samangān', 1127768] ['Rustāq', 'Afghanistan', 'Takhār', 1128265] ['Qarqīn', 'Afghanistan', 'Jowzjān', 1129516] ['Qarāwul', 'Afghanistan', 'Kunduz', 1129648] ['Pul-e Khumrī', 'Afghanistan', 'Wilāyat-e Baghlān', 1130490] ['Paghmān', 'Afghanistan', 'Kabul', 1131316] ['Nahrīn', 'Afghanistan', 'Wilāyat-e Baghlān', 1132495] ['Maymana', 'Afghanistan', 'Faryab', 1133453] ['Mehtar Lām', 'Afghanistan', 'Laghmān', 1133574] ['Mazār-e Sharīf', 'Afghanistan', 'Balkh', 1133616] ['Lashkar Gāh', 'Afghanistan', 'Helmand', 1134720] ['Kushk', 'Afghanistan', 'Herat', 1135158] ['Kunduz', 'Afghanistan', 'Kunduz', 1135689] ['Khōst', 'Afghanistan', 'Khowst', 1136469] ['Khulm', 'Afghanistan', 'Balkh', 1136575] ['Khāsh', 'Afghanistan', 'Nīmrūz', 1136863] ['Khanabad', 'Afghanistan', 'Kunduz', 1137168] ['Karukh', 'Afghanistan', 'Herat', 1137807] ['Kandahār', 'Afghanistan', 'Kandahār', 1138336] ['Kabul', 'Afghanistan', 'Kabul', 1138958] ['Jalālābād', 'Afghanistan', 'Nangarhār', 1139715] ['Jabal os Saraj', 'Afghanistan', 'Parvān', 1139807] ['Herāt', 'Afghanistan', 'Herat', 1140026] ['Ghormach', 'Afghanistan', 'Badghis', 1141089] ['Ghazni', 'Afghanistan', 'Ghaznī', 1141269] ['Gereshk', 'Afghanistan', 'Helmand', 1141540] ['Gardēz', 'Afghanistan', 'Paktia', 1141857] ['Fayzabad', 'Afghanistan', 'Badakhshan', 1142170] ['Farah', 'Afghanistan', 'Farah', 1142264] ['Kafir Qala', 'Afghanistan', 'Herat', 1142404] ['Charikar', 'Afghanistan', 'Parvān', 1145352] ['Barakī Barak', 'Afghanistan', 'Lowgar', 1147066] ['Bāmyān', 'Afghanistan', 'Bāmīān', 1147242] ['Balkh', 'Afghanistan', 'Balkh', 1147290] ['Baghlān', 'Afghanistan', 'Wilāyat-e Baghlān', 1147540] ['Ārt Khwājah', 'Afghanistan', 'Takhār', 1148106] ['Āsmār', 'Afghanistan', 'Konar', 1148205] ['Asadābād', 'Afghanistan', 'Konar', 1148311] ['Andkhōy', 'Afghanistan', 'Faryab', 1148658] ['Bāzārak', 'Afghanistan', 'Panjshir', 1429434] ['Markaz-e Woluswalī-ye Āchīn', 'Afghanistan', 'Nangarhār', 1469706] ['Saint John’s', 'Antigua and Barbuda', 'Saint John', 3576022] ['The Valley', 'Anguilla', 'N/A', 3573374] ['Sarandë', 'Albania', 'Vlorë', 363243] ['Kukës', 'Albania', 'Kukës', 782661] ['Korçë', 'Albania', 'Korçë', 782756] ['Gjirokastër', 'Albania', 'Gjirokastër', 783148] ['Elbasan', 'Albania', 'Elbasan', 783263] ['Burrel', 'Albania', 'Dibër', 783493] ['Vlorë', 'Albania', 'Vlorë', 3183719] ['Tirana', 'Albania', 'Tiranë', 3183875] ['Shkodër', 'Albania', 'Shkodër', 3184081] ['Patos Fshat', 'Albania', 'Fier', 3184517] ['Lushnjë', 'Albania', 'Fier', 3184862] ['Lezhë', 'Albania', 'Lezhë', 3184935] ['Laç', 'Albania', 'Lezhë', 3185012] ['Kuçovë', 'Albania', 'Berat', 3185060] ['Krujë', 'Albania', 'Durrës', 3185082] ['Kavajë', 'Albania', 'Tiranë', 3185211] ['Fier-Çifçi', 'Albania', 'Fier', 3185670] ['Fier', 'Albania', 'Fier', 3185672] ['Durrës', 'Albania', 'Durrës', 3185728] ['Berat', 'Albania', 'Berat', 3186084] ['Kapan', 'Armenia', 'Syunik Province', 174875] ['Goris', 'Armenia', 'Syunik Province', 174895] ['Hats’avan', 'Armenia', 'Syunik Province', 174972] ['Artashat', 'Armenia', 'Ararat Province', 174979] ['Ararat', 'Armenia', 'Ararat Province', 174991] ['Yerevan', 'Armenia', 'Yerevan', 616052] ['Ejmiatsin', 'Armenia', 'Armavir Province', 616062] ['Spitak', 'Armenia', 'Lori Province', 616199] ['Sevan', 'Armenia', 'Gegharkunik Province', 616250] ['Masis', 'Armenia', 'Ararat Province', 616435] ['Vanadzor', 'Armenia', 'Lori Province', 616530] ['Gavarr', 'Armenia', 'Gegharkunik Province', 616599] ['Hrazdan', 'Armenia', 'Kotayk Province', 616629] ['Armavir', 'Armenia', 'Armavir Province', 616631] ['Gyumri', 'Armenia', 'Shirak Province', 616635] ['Ashtarak', 'Armenia', 'Aragatsotn Province', 616877] ['Abovyan', 'Armenia', 'Kotayk Province', 617026]