User:Menno Harder/prototype-countries

From XPUB & Lens-Based wiki


python process_data.py nl

import sys

in_ = sys.argv[1]
print in_
file_ = open('data.txt', 'r')

dict_={}

for line in file_.readlines():
    list_val = line.split("  ")     
    clean_list = filter(None, list_val)
    values = []
    for i, item in enumerate(clean_list):
        
        if i == 0:
            nm = str(item[1:])
            dict_[ nm ] = ""
        elif i > 0 and i < 6:
            values.append(int(item))
    dict_[ nm ] = values

print dict_[ in_ ]
# [' gb', '20', ' 20', '0', '1', '1', 'United Kingdom\n']


data.txt

 net      326737922  340994904   14256982     391899   28117238    Networks
 com      156244063  193834652   37590589    2830514   22467045    Commercial
 jp        64453007   64642065     189058      63007     878239    Japan
 br        26576848   27069867     493019        577     163144    Brazil
 it        25662458   25729286      66828      42814     750147    Italy
 cn        20602175   21071739     469564       4234      13457    China
 de        20042730   20264841     222111     187015    5529186    Germany
 fr        17266304   17375275     108971      31869     665831    France
 au        17081052   17191550     110498         71      95979    Australia
 mx        16233310   17161659     928349        905     120755    Mexico
 ru        14533447   15371950     838503      89997    3809519    Russian Federation
 nl        13698582   13897947     199365      68458    3698306    Netherlands
 pl        13265387   13372114     106727      20354    2252241    Poland
 edu       12479074   12907525     428451       5515    4083321    Educational
 ar        11232185   11427593     195408         38      12927    Argentina
 ca         8743054    9107800     364746      35077    1087068    Canada
 uk         8106857    9190095    1083238         81     114701    United Kingdom
 tr         7093037    7258701     165664         28       7219    Turkey
 in         6746392    6793021      46629       6965      54085    India
 tw         6271944    6331357      59413       1240      28419    Taiwan, Province Of China
 se         5978228    6077929      99701      15758     534482    Sweden
 ch         5301437    5414854     113417      29656    1594111    Switzerland
 be         5191904    5230184      38280      18664     317171    Belgium
 fi         4762553    4794584      32031      14859    2073587    Finland
 za         4761282    4864432     103150         34      19339    South Africa
 co         4409710    4677802     268092       2332      15101    Colombia
 dk         4297161    4340877      43716      19021     200897    Denmark
 es         4227727    4264075      36348      11485     615760    Spain
 cz         4148325    4189753      41428      23638    1365156    Czech Republic
 pt         3747512    3759028      11516       5927     318638    Portugal
 no         3587656    3617726      30070      13851     350288    Norway
 at         3512044    3554867      42823      24888     430331    Austria
 th         3399183    3411831      12648         14       4011    Thailand
 gr         3201267    3215631      14364       8804     143876    Greece
 hu         3145467    3161546      16079      18009     746655    Hungary
 arpa       3048374    4396329    1347955         83      12216    Mistakes
 nz         3025871    3076197      50326         24      21537    New Zealand
 ro         2667382    2858899     191517      22493    1939793    Romania
 mil        2613748    4173860    1560112        186     133966    US Military
 il         2482791    2530744      47953         18      10396    Israel
 gov        2359885    3207393     847508       1987     671030    Government
 ua         2173281    2384697     211416       1840      98877    Ukraine
 cl         2151854    2171561      19707       9187      45350    Chile
 org        2139122    2330987     191865     271306    1427918    Organizations
 us         2109591    2234445     124854      18194      69601    United States
 sg         1960390    1971992      11602        663       7724    Singapore
 ie         1386917    1398166      11249       8166     294371    Ireland
 sk         1384295    1390785       6490       6220     415077    Slovakia (Slovak Republic)
 id         1343615    1387627      44012         20       3557    Indonesia
 lt         1205452    1207454       2002       4753     454398    Lithuania
 rs         1102534    1105420       2886       1186      59557
 uy         1035943    1039125       3182          7       1453    Uruguay
 ve         1015617    1028625      13008         28       3018    Venezuela
 bg          976277    1097550     121273       2231     785167    Bulgaria
 hk          870041     874513       4472        984      44112    Hong Kong
 ee          865494     870564       5070       3468     120769    Estonia
 unknown     808858   14123278   13314420     256856     447537    Unknown
 hr          729420     731138       1718       1464      77076    Croatia (local name: Hrvatska)
 md          711564     713127       1563        983     608965    Moldova, Republic Of
 info        518752     610987      92235      66896     469105    Info
 ph          425812     470197      44385        547      22682    Philippines
 my          422470     643998     221528        319       8809    Malaysia
 si          415581     418761       3180       3926      30229    Slovenia
 do          404500     444327      39827         42        486    Dominican Republic
 is          369969     372385       2416       2552      93605    Iceland
 pk          365813     505303     139490        118      23076    Pakistan
 lv          359604     363558       3954       3457     223925    Latvia
 ge          357864     358601        737        560      18139    Georgia
 gt          357552     361186       3634          9        928    Guatemala
 ae          337804     373755      35951       1459       2513    United Arab Emirates
 su          332037     403157      71120      50776     245028    Soviet Union
 kr          315697     326011      10314        413      19664    Korea, Republic Of
 ni          296068     299561       3493         16       1070    Nicaragua
 by          295217     306822      11605       1329      65357    Belarus
 py          280658     285029       4371          9       1168    Paraguay
 ma          277338     281748       4410        856       1544    Morocco
 cy          252013     254515       2502          9        825    Cyprus
 lu          250900     265070      14170       1757      34002    Luxembourg
 tt          241690     243751       2061         34        312    Trinidad And Tobago
 pe          234102     236733       2631        443       4513    Peru
 eu          201116     223930      22814      18616      78716    European Union
 eg          200430     216059      15629         18        829    Egypt
 ir          197804     199084       1280        430     112890    Iran (Islamic Republic Of)
 am          194142     199174       5032       1114      78543    Armenia
 vn          189553    1708276    1518723       1074      51994    Viet Nam
 bo          180988     182564       1576         56      54472    Bolivia
 ec          170538     172743       2205        764      43000    Ecuador
 ba          155252     164776       9524        339      27877    Bosnia And Herzegowina
 cr          147258     156865       9607        131        934    Costa Rica
 sa          145941     287193     141252         61       1533    Saudi Arabia
 tv          145158     148482       3324       6714      72436    Tuvalu
 an          138575     138669         94        100      45450    Netherlands Antilles
 biz         117434     136901      19467      30144      71594    Businesses
 kg          115573     116462        889        321      59263    Kyrgyzstan
 mz           89737      90867       1130         20       9217    Mozambique
 nu           79508      82256       2748       2875      55493    Niue
 na           78280      78490        210         28      70232    Namibia
 io           75006      85248      10242        344        942    British Indian Ocean Territory
 tc           73217      73565        348        269       4935    Turks And Caicos Islands
 bd           71164      80557       9393          8        268    Bangladesh
 ke           71018      94469      23451          6       1092    Kenya
 jo           69473     178555     109082        240      47336    Jordan
 kz           67464      71461       3997       3054      16413    Kazakhstan
 lb           64926      89282      24356          6        442    Lebanon
 mk           62826      63245        419        113       1229    Macedonia, The Former Yugoslav Republic Of
 gh           59086      60390       1304         12        101    Ghana
 uz           56075      71833      15758        400       8806    Uzbekistan
 mu           51139      52188       1049        227      51009    Mauritius
 bn           49457      54458       5001         16       1895    Brunei Darussalam
 bh           47727      48002        275         72        407    Bahrain
 az           46856      48973       2117        586      37592    Azerbaijan
 cc           42820      54631      11811       5468      26946    Cocos (Keeling) Islands
 ps           42435      43027        592        146      14153
 np           41256      51346      10090          9        288    Nepal
 aw           40560      40570         10         35      39042    Aruba
 mg           38392      38478         86        203      10628    Madagascar
 pf           37949      37962         13         59       1118    French Polynesia
 nc           34231      34251         20        372       7490    New Caledonia
 ye           33206      33211          5         17        169    Yemen
 ug           32683      33179        496         42        425    Uganda
 re           32657      32668         11         91      32626    Reunion
 hn           30955      32339       1384        267       3159    Honduras
 zw           30615      34229       3614         11       1945    Zimbabwe
 ad           28383      28395         12        648      27716    Andorra
 tz           26074      26471        397          6        507    Tanzania, United Republic Of
 mc           26009      26022         13        119       1128    Monaco
 gy           24936      31071       6135         30        114    Guyana
 sv           24070      24607        537          9        600    El Salvador
 ky           23472      23787        315        194        385    Cayman Islands
 fj           21739      21799         60          7        260    Fiji
 coop         21259      21432        173        692      16774    Cooperatives
 ao           20703      20824        121         51        379    Angola
 bs           20661      20694         33         58      20623    Bahamas
 mn           20084      20211        127        244      19859    Mongolia
 bm           20040      27470       7430        559       4558    Bermuda
 int          19428      40261      20833        176       1249    International Organizations
 ws           18013      19273       1260       3030      11358    Samoa
 ly           17926      18009         83        144        141    Libyan Arab Jamahiriya
 zm           16571      17349        778         29      13776    Zambia
 gl           15645      15692         47        111      15616    Greenland
 al           15528      24346       8818        137        887    Albania
 mt           14754      15235        481         11        494    Malta
 bt           14590      14897        307         28       2222    Bhutan
 om           14531      15358        827         74        264    Oman
 li           14278      18443       4165        923       4330    Liechtenstein
 kh           13784      15076       1292          7        165    Cambodia
 cat          13197      13432        235        510      12554    Catalan community
 ag           11532      13500       1968        470      10452    Antigua And Barbuda
 ls           11030      11042         12          5         82    Lesotho
 pa           11022      11779        757         19        688    Panama
 sm           11015      13051       2036         61      11003    San Marino
 cm           10207      10229         22        104      10167    Cameroon
 me           10088      11028        940       3247       5380
 lk            9552      81160      71608        720       2737    Sri Lanka
 ci            9115       9396        281        176       3772    Cote D'Ivoire
 nr            8162       8191         29          5        261    Nauru
 aq            7764       7772          8         14         81    Antarctica
 fo            7575       7634         59        439       3167    Faroe Islands
 ac            6265       6336         71        224       5295    Ascension Island
 tj            6258       6275         17        135        439    Tajikistan
 vu            5655       5670         15         75        513    Vanuatu
 to            5367       6378       1011       1393       3540    Tonga
 pg            5006       5108        102          6        389    Papua New Guinea
 travel        4898       5019        121       4774       4804    Travel
 vi            4790       4809         19         54       4752    Virgin Islands (U.S.)
 fm            4668       4827        159        635       1121    Micronesia, Federated States Of
 sb            4370       4375          5          7         79    Solomon Islands
 name          4209       5153        944       1618       2435    Individuals
 yu            4029       4088         59         17       1683    Yugoslavia
 mobi          3936       8566       4630       1213       1614
 jm            3906       3945         39          8        217    Jamaica
 ck            3562       3569          7         30          9    Cook Islands
 gi            3509       3546         37        122       3451    Gibraltar
 bz            3392       4502       1110       1103       2572    Belize
 pro           3299       3759        460        706       1087    Professionals
 mv            3296       3324         28         22         74    Maldives
 cu            3244      12748       9504        217       1337    Cuba
 cx            3028       3427        399        640       2615    Christmas Island
 asia          2969       3777        808        624       2341    Asia
 aero          2850       3035        185        459       2687    Air-transport industry
 kw            2771       2960        189          8        398    Kuwait
 wf            2760       2760          0         12         34    Wallis And Futuna Islands
 sz            2744       2985        241         17        434    Swaziland
 cd            2515       2541         26         92       1726    Congo (Democratic Republic)
 ms            2431       4076       1645        269        994    Montserrat
 as            2387       2515        128        466       2058    American Samoa
 tk            2069       3272       1203       1317       1084    Tokelau
 bw            1806       1853         47         67        792    Botswana
 bf            1795       1797          2         64        103    Burkina Faso
 st            1678       2001        323        430       1403    Sao Tome And Principe
 la            1532       9332       7800        507       1194    Lao People's Democratic Republic
 bb            1524       1577         53         73       1435    Barbados
 rw            1447       1458         11         25       1393    Rwanda
 ng            1234       1325         91         10        187    Nigeria
 tg            1168       1406        238         20       1163    Togo
 mw            1099       1148         49         46        176    Malawi
 mm            1055       1091         36          8         50    Myanmar
 qa             897        937         40         46        398    Qatar
 im             895       1000        105        333        561    Isle of Man
 dm             723        969        246         24        706    Dominica
 tm             714        740         26         46        565    Turkmenistan
 er             701        910        209          7         61    Eritrea
 dz             676       5243       4567        132        563    Algeria
 gm             656        662          6         35        632    Gambia
 xxx            639       1562        923        104        583
 tn             576        710        134         60        469    Tunisia
 ht             555       3584       3029         30        291    Haiti
 vg             505        528         23        175        394    Virgin Islands (British)
 bj             491        503         12         23        488    Benin
 gs             470        492         22        174        300    South Georgia And The South Sandwich Islands
 pr             469        510         41         24        220    Puerto Rico
 sh             464        493         29        183        371    St. Helena
 ne             454        463          9        136        148    Niger
 ml             437        441          4         12         37    Mali
 sy             416        469         53         23        383    Syrian Arab Republic
 tp             393        397          4          9        390    East Timor
 ki             327        328          1         11        301    Kiribati
 mo             327        332          5          9        173    Macau
 vc             305        388         83        164        213    Saint Vincent And The Grenadines
 sl             282        288          6         20        275    Sierra Leone
 ai             269        298         29        143        159    Anguilla
 je             264        297         33        126        222    Jersey
 tl             252        313         61         46        215
 sc             247        401        154        169        178    Seychelles
 gg             239        265         26        124        194    Guernsey
 sn             237        323         86         69        219    Senegal
 bi             229        240         11         48         90    Burundi
 af             223        265         42         24        145    Afghanistan
 dj             215        237         22        106        174    Djibouti
 sr             188        191          3         56         82    Suriname
 so             186        193          7        103        128    Somalia
 et             179        184          5         17        112    Ethiopia
 gp             146        147          1        121        140    Guadeloupe
 nf             128        130          2         21        113    Norfolk Island
 ga             127        133          6         64        119    Gabon
 fk             110        112          2          5         11    Falkland Islands (Malvinas)
 gf             108        108          0          3        108    French Guiana
 jobs           107        126         19        101         86    Jobs
 va             107        110          3         21        107    Vatican City State (Holy See)
 hm             102        206        104         30         60    Heard And Mc Donald Islands
 lc             100        103          3         30         83    Saint Lucia
 sd              99        105          6         30         72    Sudan
 gw              90         92          2         90         38    Guinea-Bissau
 gd              80         81          1         48         63    Grenada
 tel             61         70          9         20         30    Tel
 kn              54         59          5          5          6    Saint Kitts And Nevis
 tf              53         62          9         25         40    French Southern Territories
 cg              45        533        488          8         32    Congo (Republic)
 cv              38         43          5         24         31    Cape Verde
 museum          32         40          8         22         24    Museums
 mq              30         33          3         28         25    Martinique
 iq              26         31          5          6         24    Iraq
 pn              26         29          3         14         16    Pitcairn
 gu              23         26          3          3          6    Guam
 mr              22         22          0         13         21    Mauritania
 cf              20         20          0          5         20    Central African Republic
 gb              20         20          0          1          1    United Kingdom
 mp              17         18          1         10         12    Northern Mariana Islands
 gn              15         15          0          4         12    Guinea
 pm              15         17          2         12          9    St. Pierre And Miquelon
 km              14         14          0          8         11    Comoros
 kp               8          8          0          4          7    Korea, Democratic People's Republic Of
 gq               7          7          0          2          7    Equatorial Guinea
 lr               7          8          1          4          4    Liberia
 bv               6          6          0          1          1    Bouvet Island
 td               6          6          0          2          5    Chad
 pw               4          5          1          3          2    Palau
 yt               4          4          0          4          2    Mayotte
 mh               3          4          1          3          1    Marshall Islands
 sj               0          0          0          0          0    Svalbard And Jan Mayen Islands