data_package 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9bb5f38b73d7574924c6cc18fe28506566d61228
4
- data.tar.gz: b6b2bcd9ab3f67cf3a07422b1f41211c4dfab8da
3
+ metadata.gz: e567c149226c03fee2d2c25f524d46decb1b2963
4
+ data.tar.gz: d98b2f8edf777fb58b46d0cda63431f4f98ba229
5
5
  SHA512:
6
- metadata.gz: 7322ef232c56454c1d87115f052b051d5744c09a82bb0bd8c96ac8ca61dbc6d6f4cb052cc293f293e4dce6f4dde7ae75bee8a4bfa369ccef6f5e9883ebdeb2a0
7
- data.tar.gz: 4c9c3b153fe66838671028afc92126f819a4190e4e46720f1ae901631768f3aeb635c0b2e290d0daa8175b87a841e99d244f6b0791e502c3b96c7d06e8cb29d0
6
+ metadata.gz: 6806f16ae383a4a8afecf2f5f38cd26ec8a47d64ea76b16f824c81e75d3f086c31de7a7a43380f440b7fa2d06d2f2b09b7ee7f41792ae6686224588a39c9bbff
7
+ data.tar.gz: a120c9dd83674e0864d6f5d837bbe273a2239f91ea7d1373911b2a69cd6febc49065c2d03c7b92b6dfd6b180ea0c875b6a3219ff46b081a14afee154a6c8f1db
@@ -69,22 +69,22 @@ module AttrHelper
69
69
  end
70
70
  end
71
71
 
72
- def attributes
73
- required_attributes + optional_attributes
74
- end
75
-
76
72
  def required_attributes
77
- self.class.required_attributes.select do |attribute|
78
- attribute.required?(self)
79
- end
73
+ self.class.required_attributes
80
74
  end
81
75
 
82
76
  def optional_attributes
83
77
  self.class.optional_attributes
84
78
  end
85
79
 
80
+ def attributes
81
+ required_attributes + optional_attributes
82
+ end
83
+
86
84
  def missing_attributes
87
85
  required_attributes.select do |attribute|
86
+ attribute.required?(self)
87
+ end.select do |attribute|
88
88
  value = send(attribute.name)
89
89
  value.respond_to?(:empty?) ? value.empty? : value.nil?
90
90
  end
@@ -1,3 +1,3 @@
1
1
  module DataPackage
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
  require 'klass_helper'
3
3
 
4
- describe AttrHelper do
4
+ describe AttrHelper::Base do
5
5
  it "should initialize" do
6
6
  obj = KlassHelper::BaseKlass.new(:name => 'myvalue')
7
7
 
@@ -12,7 +12,7 @@ describe AttrHelper do
12
12
  obj.attr_required?(:format).should == false
13
13
 
14
14
  obj.missing_attributes.collect(&:name).should == [:data, :path, :url, :email, :web]
15
- obj.required_attributes.collect(&:name).should == [:name, :data, :path, :url, :email, :web]
15
+ obj.required_attributes.collect(&:name).should == [:name, :data, :path, :url, :dialect, :email, :web]
16
16
 
17
17
  obj.attr_present?(:name).should == true
18
18
  obj.attr_missing?(:name).should == false
@@ -31,7 +31,7 @@ describe AttrHelper do
31
31
  obj.attr_required?(:format).should == false
32
32
 
33
33
  obj.missing_attributes.collect(&:name).should == [:data, :path, :url, :email, :web]
34
- obj.required_attributes.collect(&:name).should == [:name, :data, :path, :url, :email, :web]
34
+ obj.required_attributes.collect(&:name).should == [:name, :data, :path, :url, :dialect, :email, :web]
35
35
 
36
36
  obj.attr_present?(:name).should == true
37
37
  obj.attr_missing?(:name).should == false
@@ -44,11 +44,11 @@ describe AttrHelper do
44
44
  obj = KlassHelper::ChildKlass.new(:name => 'myvalue')
45
45
 
46
46
  obj.missing_attributes.collect(&:name).should == [:data, :path, :url, :email, :web]
47
- obj.required_attributes.collect(&:name).should == [:name, :data, :path, :url, :email, :web]
47
+ obj.required_attributes.collect(&:name).should == [:name, :data, :path, :url, :dialect, :email, :web]
48
48
 
49
49
  obj.path = 'data.csv'
50
50
  obj.missing_attributes.collect(&:name).should == [:email, :web]
51
- obj.required_attributes.collect(&:name).should == [:name, :path, :email, :web]
51
+ obj.required_attributes.collect(&:name).should == [:name, :data, :path, :url, :dialect, :email, :web]
52
52
  end
53
53
 
54
54
  it "should write attributes through the setters" do
@@ -15,6 +15,20 @@ describe DataPackage::Resource do
15
15
  resource.to_hash.should == standard_resource.merge('format' => 'csv', 'dialect' => DataPackage::Dialect.new.to_hash)
16
16
  end
17
17
 
18
+ it "should initialize and deserialize a remote resource" do
19
+ resource = DataPackage::Resource.new(base_path, remote_resource)
20
+
21
+ resource.format.should == 'csv'
22
+ resource.name.should == 'country-codes'
23
+ resource.path.should == 'data/country-codes.csv'
24
+ resource.url.should == 'https://datahub.com/datasets/country-codes.csv'
25
+
26
+ resource.schema.fields.length.should == 3
27
+ resource.schema.primary_key.should == ['id']
28
+
29
+ resource.to_hash.should == remote_resource.merge('format' => 'csv')
30
+ end
31
+
18
32
  describe "#each_row" do
19
33
  it "should enumerate over inline data" do
20
34
  resource = DataPackage::Resource.new(base_path, inline_resource)
@@ -0,0 +1,71 @@
1
+ Comprehensive country code information, including ISO 3166 codes, ITU dialing
2
+ codes, ISO 4217 currency codes, and many others. Provided as a Simple Data
3
+ Format Data Package.
4
+
5
+ ## Data
6
+
7
+ Data comes from multiple sources as follows.
8
+
9
+ ISO 3166 offical English and French short names are from
10
+ [iso.org](http://www.iso.org/iso/country_codes/iso_3166_code_lists.htm)
11
+
12
+ ISO 4217 currency codes are from
13
+ [currency-iso.org](http://www.currency-iso.org/dl_iso_table_a1.xml)
14
+
15
+ Many other country codes are from
16
+ [statoids.com](http://www.statoids.com/wab.html)
17
+
18
+ Special thanks to Gwillim Law for his excellent
19
+ [statoids.com](http://www.statoids.com) site (some of the field descriptions
20
+ are excerpted from his site), which is more up-to-date than most similar
21
+ resources and is much easier to scrape than multiple Wikipedia pages.
22
+
23
+ ## Preparation
24
+
25
+ This package includes a Python script to fetch current country information
26
+ and output a JSON document of combined country code information.
27
+ Per-country JSON documents may be keyed by any of the fields below.
28
+
29
+ CSV output is provided via the `in2csv` and `csvcut` utilities from [csvkit](http://github.com/onyxfish/csvkit)
30
+
31
+ Run **scripts/get_countries_of_earth.py --help** for usage information
32
+
33
+ ### data/country-codes.csv
34
+
35
+ Install requirements:
36
+
37
+ pip install -r scripts/requirements.pip
38
+
39
+
40
+ Run the python script to generate json file:
41
+
42
+ python scripts/get_countries_of_earth.py -l
43
+
44
+
45
+ Convert json file to csv (and reorder columns):
46
+
47
+ in2csv data/country-codes.json > data/country-codes.csv
48
+ python scripts/reorder_columns.py
49
+
50
+
51
+ ## License
52
+
53
+ This material is licensed by its maintainers under the Public Domain Dedication
54
+ and License.
55
+
56
+ Nevertheless, it should be noted that this material is ultimately sourced from
57
+ ISO and other standards bodies and their rights and licensing policies are somewhat
58
+ unclear. As this is a short, simple database of facts there is a strong argument
59
+ that no rights can subsist in this collection. However, ISO state on [their
60
+ site](http://www.iso.org/iso/home/standards/country_codes.htm):
61
+
62
+ > ISO makes the list of alpha-2 country codes available for internal use and
63
+ > non-commercial purposes free of charge.
64
+
65
+ This carries the implication (though not spelled out) that other uses are not
66
+ permitted and that, therefore, there may be rights preventing further general
67
+ use and reuse.
68
+
69
+ If you intended to use these data in a public or commercial product, please
70
+ check the original sources for any specific restrictions.
71
+
@@ -0,0 +1,250 @@
1
+ name,name_fr,ISO3166-1-Alpha-2,ISO3166-1-Alpha-3,ISO3166-1-numeric,ITU,MARC,WMO,DS,Dial,FIFA,FIPS,GAUL,IOC,currency_alphabetic_code,currency_country_name,currency_minor_unit,currency_name,currency_numeric_code,is_independent
2
+ Afghanistan,Afghanistan,AF,AFG,004,AFG,af,AF,AFG,93,AFG,AF,1,AFG,AFN,AFGHANISTAN,2,Afghani,971,Yes
3
+ Albania,Albanie,AL,ALB,008,ALB,aa,AB,AL,355,ALB,AL,3,ALB,ALL,ALBANIA,2,Lek,008,Yes
4
+ Algeria,Algérie,DZ,DZA,012,ALG,ae,AL,DZ,213,ALG,AG,4,ALG,DZD,ALGERIA,2,Algerian Dinar,012,Yes
5
+ American Samoa,Samoa Américaines,AS,ASM,016,SMA,as, ,USA,1-684,ASA,AQ,5,ASA,USD,AMERICAN SAMOA,2,US Dollar,840,Territory of US
6
+ Andorra,Andorre,AD,AND,020,AND,an, ,AND,376,AND,AN,7,AND,EUR,ANDORRA,2,Euro,978,Yes
7
+ Angola,Angola,AO,AGO,024,AGL,ao,AN, ,244,ANG,AO,8,ANG,AOA,ANGOLA,2,Kwanza,973,Yes
8
+ Anguilla,Anguilla,AI,AIA,660,AIA,am, , ,1-264,AIA,AV,9,AIA,XCD,ANGUILLA,2,East Caribbean Dollar,951,Territory of GB
9
+ Antarctica,Antarctique,AQ,ATA,010, ,ay,AA, ,672,ROS,AY,10, ,,ANTARCTICA,,No universal currency,,International
10
+ Antigua and Barbuda,Antigua-Et-Barbuda,AG,ATG,028,ATG,aq,AT, ,1-268,ATG,AC,11,ANT,XCD,ANTIGUA AND BARBUDA,2,East Caribbean Dollar,951,Yes
11
+ Argentina,Argentine,AR,ARG,032,ARG,ag,AG,RA,54,ARG,AR,12,ARG,ARS,ARGENTINA,2,Argentine Peso,032,Yes
12
+ Armenia,Arménie,AM,ARM,051,ARM,ai,AY,AM,374,ARM,AM,13,ARM,AMD,ARMENIA,2,Armenian Dram,051,Yes
13
+ Aruba,Aruba,AW,ABW,533,ABW,aw,NU, ,297,ARU,AA,14,ARU,AWG,ARUBA,2,Aruban Florin,533,Part of NL
14
+ Australia,Australie,AU,AUS,036,AUS,at,AU,AUS,61,AUS,AS,17,AUS,AUD,AUSTRALIA,2,Australian Dollar,036,Yes
15
+ Austria,Autriche,AT,AUT,040,AUT,au,OS,A,43,AUT,AU,18,AUT,EUR,AUSTRIA,2,Euro,978,Yes
16
+ Azerbaijan,Azerbaïdjan,AZ,AZE,031,AZE,aj,AJ,AZ,994,AZE,AJ,19,AZE,AZN,AZERBAIJAN,2,Azerbaijanian Manat,944,Yes
17
+ Bahamas,Bahamas,BS,BHS,044,BAH,bf,BA,BS,1-242,BAH,BF,20,BAH,BSD,BAHAMAS,2,Bahamian Dollar,044,Yes
18
+ Bahrain,Bahreïn,BH,BHR,048,BHR,ba,BN,BRN,973,BHR,BA,21,BRN,BHD,BAHRAIN,3,Bahraini Dinar,048,Yes
19
+ Bangladesh,Bangladesh,BD,BGD,050,BGD,bg,BW,BD,880,BAN,BG,23,BAN,BDT,BANGLADESH,2,Taka,050,Yes
20
+ Barbados,Barbade,BB,BRB,052,BRB,bb,BR,BDS,1-246,BRB,BB,24,BAR,BBD,BARBADOS,2,Barbados Dollar,052,Yes
21
+ Belarus,Bélarus,BY,BLR,112,BLR,bw,BY,BY,375,BLR,BO,26,BLR,BYR,BELARUS,0,Belarussian Ruble,974,Yes
22
+ Belgium,Belgique,BE,BEL,056,BEL,be,BX,B,32,BEL,BE,27,BEL,EUR,BELGIUM,2,Euro,978,Yes
23
+ Belize,Belize,BZ,BLZ,084,BLZ,bh,BH,BZ,501,BLZ,BH,28,BIZ,BZD,BELIZE,2,Belize Dollar,084,Yes
24
+ Benin,Bénin,BJ,BEN,204,BEN,dm,BJ,DY,229,BEN,BN,29,BEN,XOF,BENIN,0,CFA Franc BCEAO,952,Yes
25
+ Bermuda,Bermudes,BM,BMU,060,BER,bm,BE, ,1-441,BER,BD,30,BER,BMD,BERMUDA,2,Bermudian Dollar,060,Territory of GB
26
+ Bhutan,Bhoutan,BT,BTN,064,BTN,bt, , ,975,BHU,BT,31,BHU,INR,BHUTAN,2,Indian Rupee,356,Yes
27
+ "Bolivia, Plurinational State of","Bolivie, l'État Plurinational de",BO,BOL,068,BOL,bo,BO,BOL,591,BOL,BL,33,BOL,BOB,"BOLIVIA, PLURINATIONAL STATE OF",2,Boliviano,068,Yes
28
+ "Bonaire, Sint Eustatius and Saba","Bonaire, Saint-Eustache et Saba",BQ,BES,535,ATN,ca,NU,NA,599,ANT,NL,176,AHO,USD,"BONAIRE, SINT EUSTATIUS AND SABA",2,US Dollar,840,Part of NL
29
+ Bosnia and Herzegovina,Bosnie-Herzégovine,BA,BIH,070,BIH,bn,BG,BIH,387,BIH,BK,34,BIH,BAM,BOSNIA AND HERZEGOVINA,2,Convertible Mark,977,Yes
30
+ Botswana,Botswana,BW,BWA,072,BOT,bs,BC,BW,267,BOT,BC,35,BOT,BWP,BOTSWANA,2,Pula,072,Yes
31
+ Bouvet Island,"Bouvet, Île",BV,BVT,074, ,bv,BV, ,47,,BV,36, ,NOK,BOUVET ISLAND,2,Norwegian Krone,578,Territory of NO
32
+ Brazil,Brésil,BR,BRA,076,B,bl,BZ,BR,55,BRA,BR,37,BRA,BRL,BRAZIL,2,Brazilian Real,986,Yes
33
+ British Indian Ocean Territory,"Océan Indien, Territoire Britannique de l'",IO,IOT,086,BIO,bi, , ,246,,IO,38, ,USD,BRITISH INDIAN OCEAN TERRITORY,2,US Dollar,840,Territory of GB
34
+ Brunei Darussalam,Brunei Darussalam,BN,BRN,096,BRU,bx,BD,BRU,673,BRU,BX,40,BRU,BND,BRUNEI DARUSSALAM,2,Brunei Dollar,096,Yes
35
+ Bulgaria,Bulgarie,BG,BGR,100,BUL,bu,BU,BG,359,BUL,BU,41,BUL,BGN,BULGARIA,2,Bulgarian Lev,975,Yes
36
+ Burkina Faso,Burkina Faso,BF,BFA,854,BFA,uv,HV,BF,226,BFA,UV,42,BUR,XOF,BURKINA FASO,0,CFA Franc BCEAO,952,Yes
37
+ Burundi,Burundi,BI,BDI,108,BDI,bd,BI,RU,257,BDI,BY,43,BDI,BIF,BURUNDI,0,Burundi Franc,108,Yes
38
+ Cambodia,Cambodge,KH,KHM,116,CBG,cb,KP,K,855,CAM,CB,44,CAM,KHR,CAMBODIA,2,Riel,116,Yes
39
+ Cameroon,Cameroun,CM,CMR,120,CME,cm,CM,CAM,237,CMR,CM,45,CMR,XAF,CAMEROON,0,CFA Franc BEAC,950,Yes
40
+ Canada,Canada,CA,CAN,124,CAN,xxc,CN,CDN,1,CAN,CA,46,CAN,CAD,CANADA,2,Canadian Dollar,124,Yes
41
+ Cape Verde,Cap-Vert,CV,CPV,132,CPV,cv,CV, ,238,CPV,CV,47,CPV,CVE,CAPE VERDE,2,Cape Verde Escudo,132,Yes
42
+ Cayman Islands,"Caïmans, Îles",KY,CYM,136,CYM,cj,GC, ,1-345,CAY,CJ,48,CAY,KYD,CAYMAN ISLANDS,2,Cayman Islands Dollar,136,Territory of GB
43
+ Central African Republic,"Centrafricaine, République",CF,CAF,140,CAF,cx,CE,RCA,236,CTA,CT,49,CAF,XAF,CENTRAL AFRICAN REPUBLIC,0,CFA Franc BEAC,950,Yes
44
+ Chad,Tchad,TD,TCD,148,TCD,cd,CD,TCH,235,CHA,CD,50,CHA,XAF,CHAD,0,CFA Franc BEAC,950,Yes
45
+ Chile,Chili,CL,CHL,152,CHL,cl,CH,RCH,56,CHI,CI,51,CHI,CLP,CHILE,0,Chilean Peso,152,Yes
46
+ China,Chine,CN,CHN,156,CHN,cc,CI, ,86,CHN,CH,53,CHN,CNY,CHINA,2,Yuan Renminbi,156,Yes
47
+ Christmas Island,"Christmas, Île",CX,CXR,162,CHR,xa,KI,AUS,61,CXR,KT,54, ,AUD,CHRISTMAS ISLAND,2,Australian Dollar,036,Territory of AU
48
+ Cocos (Keeling) Islands,"Cocos (Keeling), Îles",CC,CCK,166,ICO,xb,KK,AUS,61,CCK,CK,56, ,AUD,COCOS (KEELING) ISLANDS,2,Australian Dollar,036,Territory of AU
49
+ Colombia,Colombie,CO,COL,170,CLM,ck,CO,CO,57,COL,CO,57,COL,COP,COLOMBIA,2,Colombian Peso,170,Yes
50
+ Comoros,Comores,KM,COM,174,COM,cq,IC, ,269,COM,CN,58,COM,KMF,COMOROS,0,Comoro Franc,174,Yes
51
+ Congo,Congo,CG,COG,178,COG,cf,CG,RCB,242,CGO,CF,59,CGO,XAF,CONGO,0,CFA Franc BEAC,950,Yes
52
+ "Congo, the Democratic Republic of the","Congo, la République Démocratique du",CD,COD,180,COD,cg,ZR,ZRE,243,COD,CG,68,COD,CDF,"CONGO, THE DEMOCRATIC REPUBLIC OF",2,Congolese Franc,976,Yes
53
+ Cook Islands,"Cook, Îles",CK,COK,184,CKH,cw,KU,NZ,682,COK,CW,60,COK,NZD,COOK ISLANDS,2,New Zealand Dollar,554,Associated with NZ
54
+ Costa Rica,Costa Rica,CR,CRI,188,CTR,cr,CS,CR,506,CRC,CS,61,CRC,CRC,COSTA RICA,2,Costa Rican Colon,188,Yes
55
+ Croatia,Croatie,HR,HRV,191,HRV,ci,RH,HR,385,CRO,HR,62,CRO,HRK,CROATIA,2,Croatian Kuna,191,Yes
56
+ Cuba,Cuba,CU,CUB,192,CUB,cu,CU,C,53,CUB,CU,63,CUB,CUP,CUBA,2,Cuban Peso,192,Yes
57
+ Curaçao,Curaçao,CW,CUW,531,,co,,,599,,UC,,,ANG,CURAÇAO,2,Netherlands Antillean Guilder,532,Part of NL
58
+ Cyprus,Chypre,CY,CYP,196,CYP,cy,CY,CY,357,CYP,CY,64,CYP,EUR,CYPRUS,2,Euro,978,Yes
59
+ Czech Republic,"Tchèque, République",CZ,CZE,203,CZE,xr,CZ,CZ,420,CZE,EZ,65,CZE,CZK,CZECH REPUBLIC,2,Czech Koruna,203,Yes
60
+ Côte d'Ivoire,Côte d'Ivoire,CI,CIV,384,CTI,iv,IV,CI,225,CIV,IV,66,CIV,XOF,CÔTE D'IVOIRE,0,CFA Franc BCEAO,952,Yes
61
+ Denmark,Danemark,DK,DNK,208,DNK,dk,DN,DK,45,DEN,DA,69,DEN,DKK,DENMARK,2,Danish Krone,208,Yes
62
+ Djibouti,Djibouti,DJ,DJI,262,DJI,ft,DJ, ,253,DJI,DJ,70,DJI,DJF,DJIBOUTI,0,Djibouti Franc,262,Yes
63
+ Dominica,Dominique,DM,DMA,212,DMA,dq,DO,WD,1-767,DMA,DO,71,DMA,XCD,DOMINICA,2,East Caribbean Dollar,951,Yes
64
+ Dominican Republic,"Dominicaine, République",DO,DOM,214,DOM,dr,DR,DOM,1-8091-8291-849,DOM,DR,72,DOM,DOP,DOMINICAN REPUBLIC,2,Dominican Peso,214,Yes
65
+ Ecuador,Équateur,EC,ECU,218,EQA,ec,EQ,EC,593,ECU,EC,73,ECU,USD,ECUADOR,2,US Dollar,840,Yes
66
+ Egypt,Égypte,EG,EGY,818,EGY,ua,EG,ET,20,EGY,EG,40765,EGY,EGP,EGYPT,2,Egyptian Pound,818,Yes
67
+ El Salvador,El Salvador,SV,SLV,222,SLV,es,ES,ES,503,SLV,ES,75,ESA,USD,EL SALVADOR,2,US Dollar,840,Yes
68
+ Equatorial Guinea,Guinée Équatoriale,GQ,GNQ,226,GNE,eg,GQ, ,240,EQG,EK,76,GEQ,XAF,EQUATORIAL GUINEA,0,CFA Franc BEAC,950,Yes
69
+ Eritrea,Érythrée,ER,ERI,232,ERI,ea, , ,291,ERI,ER,77,ERI,ERN,ERITREA,2,Nakfa,232,Yes
70
+ Estonia,Estonie,EE,EST,233,EST,er,EO,EST,372,EST,EN,78,EST,EUR,ESTONIA,2,Euro,978,Yes
71
+ Ethiopia,Éthiopie,ET,ETH,231,ETH,et,ET,ETH,251,ETH,ET,79,ETH,ETB,ETHIOPIA,2,Ethiopian Birr,230,Yes
72
+ Falkland Islands (Malvinas),"Falkland, Îles (Malvinas)",FK,FLK,238,FLK,fk,FK, ,500,FLK,FK,81,FLK,FKP,FALKLAND ISLANDS (MALVINAS),2,Falkland Islands Pound,238,Territory of GB
73
+ Faroe Islands,"Féroé, Îles",FO,FRO,234,FRO,fa,FA,FO,298,FRO,FO,82,FAR,DKK,FAROE ISLANDS,2,Danish Krone,208,Part of DK
74
+ Fiji,Fidji,FJ,FJI,242,FJI,fj,FJ,FJI,679,FIJ,FJ,83,FIJ,FJD,FIJI,2,Fiji Dollar,242,Yes
75
+ Finland,Finlande,FI,FIN,246,FIN,fi,FI,FIN,358,FIN,FI,84,FIN,EUR,FINLAND,2,Euro,978,Yes
76
+ France,France,FR,FRA,250,F,fr,FR,F,33,FRA,FR,85,FRA,EUR,FRANCE,2,Euro,978,Yes
77
+ French Guiana,Guyane Française,GF,GUF,254,GUF,fg,FG,F,594,GUF,FG,86,FGU,EUR,FRENCH GUIANA,2,Euro,978,Part of FR
78
+ French Polynesia,Polynésie Française,PF,PYF,258,OCE,fp,PF,F,689,TAH,FP,87,FPO,XPF,FRENCH POLYNESIA,0,CFP Franc,953,Territory of FR
79
+ French Southern Territories,Terres Australes Françaises,TF,ATF,260, ,fs, ,F,262,,FS,88, ,EUR,FRENCH SOUTHERN TERRITORIES,2,Euro,978,Territory of FR
80
+ Gabon,Gabon,GA,GAB,266,GAB,go,GO,G,241,GAB,GB,89,GAB,XAF,GABON,0,CFA Franc BEAC,950,Yes
81
+ Gambia,Gambie,GM,GMB,270,GMB,gm,GB,WAG,220,GAM,GA,90,GAM,GMD,GAMBIA,2,Dalasi,270,Yes
82
+ Georgia,Géorgie,GE,GEO,268,GEO,gs,GG,GE,995,GEO,GG,92,GEO,GEL,GEORGIA,2,Lari,981,Yes
83
+ Germany,Allemagne,DE,DEU,276,D,gw,DL,D,49,GER,GM,93,GER,EUR,GERMANY,2,Euro,978,Yes
84
+ Ghana,Ghana,GH,GHA,288,GHA,gh,GH,GH,233,GHA,GH,94,GHA,GHS,GHANA,2,Ghana Cedi,936,Yes
85
+ Gibraltar,Gibraltar,GI,GIB,292,GIB,gi,GI,GBZ,350,GBZ,GI,95,GIB,GIP,GIBRALTAR,2,Gibraltar Pound,292,Territory of GB
86
+ Greece,Grèce,GR,GRC,300,GRC,gr,GR,GR,30,GRE,GR,97,GRE,EUR,GREECE,2,Euro,978,Yes
87
+ Greenland,Groenland,GL,GRL,304,GRL,gl,GL,DK,299,GRL,GL,98,GRL,DKK,GREENLAND,2,Danish Krone,208,Part of DK
88
+ Grenada,Grenade,GD,GRD,308,GRD,gd,GD,WG,1-473,GRN,GJ,99,GRN,XCD,GRENADA,2,East Caribbean Dollar,951,Yes
89
+ Guadeloupe,Guadeloupe,GP,GLP,312,GDL,gp,MF,F,590,GLP,GP,100,GUD,EUR,GUADELOUPE,2,Euro,978,Part of FR
90
+ Guam,Guam,GU,GUM,316,GUM,gu,GM,USA,1-671,GUM,GQ,101,GUM,USD,GUAM,2,US Dollar,840,Territory of US
91
+ Guatemala,Guatemala,GT,GTM,320,GTM,gt,GU,GCA,502,GUA,GT,103,GUA,GTQ,GUATEMALA,2,Quetzal,320,Yes
92
+ Guernsey,Guernesey,GG,GGY,831, ,uik, ,GBG,44,GBG,GK,104, ,GBP,GUERNSEY,2,Pound Sterling,826,Crown dependency of GB
93
+ Guinea,Guinée,GN,GIN,324,GUI,gv,GN,RG,224,GUI,GV,106,GUI,GNF,GUINEA,0,Guinea Franc,324,Yes
94
+ Guinea-Bissau,Guinée-Bissau,GW,GNB,624,GNB,pg,GW, ,245,GNB,PU,105,GBS,XOF,GUINEA-BISSAU,0,CFA Franc BCEAO,952,Yes
95
+ Guyana,Guyana,GY,GUY,328,GUY,gy,GY,GUY,592,GUY,GY,107,GUY,GYD,GUYANA,2,Guyana Dollar,328,Yes
96
+ Haiti,Haïti,HT,HTI,332,HTI,ht,HA,RH,509,HAI,HA,108,HAI,USD,HAITI,2,US Dollar,840,Yes
97
+ Heard Island and McDonald Mcdonald Islands,"Heard-Et-Îles Macdonald, Île",HM,HMD,334, ,hm, ,AUS,672,,HM,109, ,AUD,HEARD ISLAND AND McDONALD ISLANDS,2,Australian Dollar,036,Territory of AU
98
+ Holy See (Vatican City State),Saint-Siège (État de la Cité du Vatican),VA,VAT,336,CVA,vc, ,V,39-06,VAT,VT,110, ,EUR,Vatican City State (HOLY SEE),2,Euro,978,Yes
99
+ Honduras,Honduras,HN,HND,340,HND,ho,HO, ,504,HON,HO,111,HON,HNL,HONDURAS,2,Lempira,340,Yes
100
+ Hong Kong,Hong Kong,HK,HKG,344,HKG, ,HK,HK,852,HKG,HK,33364,HKG,HKD,HONG KONG,2,Hong Kong Dollar,344,Part of CN
101
+ Hungary,Hongrie,HU,HUN,348,HNG,hu,HU,H,36,HUN,HU,113,HUN,HUF,HUNGARY,2,Forint,348,Yes
102
+ Iceland,Islande,IS,ISL,352,ISL,ic,IL,IS,354,ISL,IC,114,ISL,ISK,ICELAND,0,Iceland Krona,352,Yes
103
+ India,Inde,IN,IND,356,IND,ii,IN,IND,91,IND,IN,115,IND,INR,INDIA,2,Indian Rupee,356,Yes
104
+ Indonesia,Indonésie,ID,IDN,360,INS,io,ID,RI,62,IDN,ID,116,INA,IDR,INDONESIA,2,Rupiah,360,Yes
105
+ "Iran, Islamic Republic of","Iran, République Islamique d'",IR,IRN,364,IRN,ir,IR,IR,98,IRN,IR,117,IRI,IRR,"IRAN, ISLAMIC REPUBLIC OF",2,Iranian Rial,364,Yes
106
+ Iraq,Iraq,IQ,IRQ,368,IRQ,iq,IQ,IRQ,964,IRQ,IZ,118,IRQ,IQD,IRAQ,3,Iraqi Dinar,368,Yes
107
+ Ireland,Irlande,IE,IRL,372,IRL,ie,IE,IRL,353,IRL,EI,119,IRL,EUR,IRELAND,2,Euro,978,Yes
108
+ Isle of Man,Île de Man,IM,IMN,833, ,uik, ,GBM,44,GBM,IM,120, ,GBP,ISLE OF MAN,2,Pound Sterling,826,Crown dependency of GB
109
+ Israel,Israël,IL,ISR,376,ISR,is,IS,IL,972,ISR,IS,121,ISR,ILS,ISRAEL,2,New Israeli Sheqel,376,Yes
110
+ Italy,Italie,IT,ITA,380,I,it,IY,I,39,ITA,IT,122,ITA,EUR,ITALY,2,Euro,978,Yes
111
+ Jamaica,Jamaïque,JM,JAM,388,JMC,jm,JM,JA,1-876,JAM,JM,123,JAM,JMD,JAMAICA,2,Jamaican Dollar,388,Yes
112
+ Japan,Japon,JP,JPN,392,J,ja,JP,J,81,JPN,JA,126,JPN,JPY,JAPAN,0,Yen,392,Yes
113
+ Jersey,Jersey,JE,JEY,832, ,uik, ,GBJ,44,GBJ,JE,128, ,GBP,JERSEY,2,Pound Sterling,826,Crown dependency of GB
114
+ Jordan,Jordanie,JO,JOR,400,JOR,jo,JD,HKJ,962,JOR,JO,130,JOR,JOD,JORDAN,3,Jordanian Dinar,400,Yes
115
+ Kazakhstan,Kazakhstan,KZ,KAZ,398,KAZ,kz,KZ,KZ,7,KAZ,KZ,132,KAZ,KZT,KAZAKHSTAN,2,Tenge,398,Yes
116
+ Kenya,Kenya,KE,KEN,404,KEN,ke,KN,EAK,254,KEN,KE,133,KEN,KES,KENYA,2,Kenyan Shilling,404,Yes
117
+ Kiribati,Kiribati,KI,KIR,296,KIR,gb,KB, ,686,KIR,KR,135,KIR,AUD,KIRIBATI,2,Australian Dollar,036,Yes
118
+ "Korea, Democratic People's Republic of","Corée, République Populaire Démocratique de",KP,PRK,408,KRE,kn,KR, ,850,PRK,KN,67,PRK,KPW,"KOREA, DEMOCRATIC PEOPLE’S REPUBLIC OF",2,North Korean Won,408,Yes
119
+ "Korea, Republic of","Corée, République de",KR,KOR,410,KOR,ko,KO,ROK,82,KOR,KS,202,KOR,KRW,"KOREA, REPUBLIC OF",0,Won,410,Yes
120
+ Kuwait,Koweït,KW,KWT,414,KWT,ku,KW,KWT,965,KUW,KU,137,KUW,KWD,KUWAIT,3,Kuwaiti Dinar,414,Yes
121
+ Kyrgyzstan,Kirghizistan,KG,KGZ,417,KGZ,kg,KG,KS,996,KGZ,KG,138,KGZ,KGS,KYRGYZSTAN,2,Som,417,Yes
122
+ Lao People's Democratic Republic,"Lao, République Démocratique Populaire",LA,LAO,418,LAO,ls,LA,LAO,856,LAO,LA,139,LAO,LAK,LAO PEOPLE’S DEMOCRATIC REPUBLIC,2,Kip,418,Yes
123
+ Latvia,Lettonie,LV,LVA,428,LVA,lv,LV,LV,371,LVA,LG,140,LAT,LVL,LATVIA,2,Latvian Lats,428,Yes
124
+ Lebanon,Liban,LB,LBN,422,LBN,le,LB,RL,961,LIB,LE,141,LIB,LBP,LEBANON,2,Lebanese Pound,422,Yes
125
+ Lesotho,Lesotho,LS,LSO,426,LSO,lo,LS,LS,266,LES,LT,142,LES,ZAR,LESOTHO,2,Rand,710,Yes
126
+ Liberia,Libéria,LR,LBR,430,LBR,lb,LI,LB,231,LBR,LI,144,LBR,LRD,LIBERIA,2,Liberian Dollar,430,Yes
127
+ Libya,Libye,LY,LBY,434,LBY,ly,LY,LAR,218,LBY,LY,145,LBA,LYD,LIBYA,3,Libyan Dinar,434,Yes
128
+ Liechtenstein,Liechtenstein,LI,LIE,438,LIE,lh, ,FL,423,LIE,LS,146,LIE,CHF,LIECHTENSTEIN,2,Swiss Franc,756,Yes
129
+ Lithuania,Lituanie,LT,LTU,440,LTU,li,LT,LT,370,LTU,LH,147,LTU,LTL,LITHUANIA,2,Lithuanian Litas,440,Yes
130
+ Luxembourg,Luxembourg,LU,LUX,442,LUX,lu,BX,L,352,LUX,LU,148,LUX,EUR,LUXEMBOURG,2,Euro,978,Yes
131
+ Macao,Macao,MO,MAC,446,MAC, ,MU, ,853,MAC,MC,149,MAC,MOP,MACAO,2,Pataca,446,Part of CN
132
+ "Macedonia, the Former Yugoslav Republic of","Macédoine, l'Ex-république Yougoslave de",MK,MKD,807,MKD,xn,MJ,MK,389,MKD,MK,241,MKD,MKD,"MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF",2,Denar,807,Yes
133
+ Madagascar,Madagascar,MG,MDG,450,MDG,mg,MG,RM,261,MAD,MA,150,MAD,MGA,MADAGASCAR,2,Malagasy Ariary,969,Yes
134
+ Malawi,Malawi,MW,MWI,454,MWI,mw,MW,MW,265,MWI,MI,152,MAW,MWK,MALAWI,2,Kwacha,454,Yes
135
+ Malaysia,Malaisie,MY,MYS,458,MLA,my,MS,MAL,60,MAS,MY,153,MAS,MYR,MALAYSIA,2,Malaysian Ringgit,458,Yes
136
+ Maldives,Maldives,MV,MDV,462,MLD,xc,MV, ,960,MDV,MV,154,MDV,MVR,MALDIVES,2,Rufiyaa,462,Yes
137
+ Mali,Mali,ML,MLI,466,MLI,ml,MI,RMM,223,MLI,ML,155,MLI,XOF,MALI,0,CFA Franc BCEAO,952,Yes
138
+ Malta,Malte,MT,MLT,470,MLT,mm,ML,M,356,MLT,MT,156,MLT,EUR,MALTA,2,Euro,978,Yes
139
+ Marshall Islands,"Marshall, Îles",MH,MHL,584,MHL,xe,MH, ,692,MHL,RM,157,MSH,USD,MARSHALL ISLANDS,2,US Dollar,840,Yes
140
+ Martinique,Martinique,MQ,MTQ,474,MRT,mq,MR,F,596,MTQ,MB,158,MRT,EUR,MARTINIQUE,2,Euro,978,Part of FR
141
+ Mauritania,Mauritanie,MR,MRT,478,MTN,mu,MT,RIM,222,MTN,MR,159,MTN,MRO,MAURITANIA,2,Ouguiya,478,Yes
142
+ Mauritius,Maurice,MU,MUS,480,MAU,mf,MA,MS,230,MRI,MP,160,MRI,MUR,MAURITIUS,2,Mauritius Rupee,480,Yes
143
+ Mayotte,Mayotte,YT,MYT,175,MYT,ot, , ,262,MYT,MF,161,MAY,EUR,MAYOTTE,2,Euro,978,Part of FR
144
+ Mexico,Mexique,MX,MEX,484,MEX,mx,MX,MEX,52,MEX,MX,162,MEX,MXN,MEXICO,2,Mexican Peso,484,Yes
145
+ "Micronesia, Federated States of","Micronésie, États Fédérés de",FM,FSM,583,FSM,fm, , ,691,FSM,FM,163,FSM,USD,"MICRONESIA, FEDERATED STATES OF",2,US Dollar,840,Yes
146
+ "Moldova, Republic of","Moldova, République de",MD,MDA,498,MDA,mv,RM,MD,373,MDA,MD,165,MDA,MDL,"MOLDOVA, REPUBLIC OF",2,Moldovan Leu,498,Yes
147
+ Monaco,Monaco,MC,MCO,492,MCO,mc, ,MC,377,MON,MN,166,MON,EUR,MONACO,2,Euro,978,Yes
148
+ Mongolia,Mongolie,MN,MNG,496,MNG,mp,MO,MGL,976,MNG,MG,167,MGL,MNT,MONGOLIA,2,Tugrik,496,Yes
149
+ Montenegro,Monténégro,ME,MNE,499,MNE,mo, ,MNE,382,MNE,MJ,2647,MGO,EUR,MONTENEGRO,2,Euro,978,Yes
150
+ Montserrat,Montserrat,MS,MSR,500,MSR,mj, , ,1-664,MSR,MH,168,MNT,XCD,MONTSERRAT,2,East Caribbean Dollar,951,Territory of GB
151
+ Morocco,Maroc,MA,MAR,504,MRC,mr,MC,MA,212,MAR,MO,169,MAR,MAD,MOROCCO,2,Moroccan Dirham,504,Yes
152
+ Mozambique,Mozambique,MZ,MOZ,508,MOZ,mz,MZ,MOC,258,MOZ,MZ,170,MOZ,MZN,MOZAMBIQUE,2,Mozambique Metical,943,Yes
153
+ Myanmar,Myanmar,MM,MMR,104,MYA,br,BM,BUR,95,MYA,BM,171,MYA,MMK,MYANMAR,2,Kyat,104,Yes
154
+ Namibia,Namibie,NA,NAM,516,NMB,sx,NM,NAM,264,NAM,WA,172,NAM,ZAR,NAMIBIA,2,Rand,710,Yes
155
+ Nauru,Nauru,NR,NRU,520,NRU,nu,NW,NAU,674,NRU,NR,173,NRU,AUD,NAURU,2,Australian Dollar,036,Yes
156
+ Nepal,Népal,NP,NPL,524,NPL,np,NP,NEP,977,NEP,NP,175,NEP,NPR,NEPAL,2,Nepalese Rupee,524,Yes
157
+ Netherlands,Pays-Bas,NL,NLD,528,HOL,ne,NL,NL,31,NED,NL,177,NED,EUR,NETHERLANDS,2,Euro,978,Yes
158
+ New Caledonia,Nouvelle-Calédonie,NC,NCL,540,NCL,nl,NC,F,687,NCL,NC,178,NCD,XPF,NEW CALEDONIA,0,CFP Franc,953,Territory of FR
159
+ New Zealand,Nouvelle-Zélande,NZ,NZL,554,NZL,nz,NZ,NZ,64,NZL,NZ,179,NZL,NZD,NEW ZEALAND,2,New Zealand Dollar,554,Yes
160
+ Nicaragua,Nicaragua,NI,NIC,558,NCG,nq,NK,NIC,505,NCA,NU,180,NCA,NIO,NICARAGUA,2,Cordoba Oro,558,Yes
161
+ Niger,Niger,NE,NER,562,NGR,ng,NR,RN,227,NIG,NG,181,NIG,XOF,NIGER,0,CFA Franc BCEAO,952,Yes
162
+ Nigeria,Nigéria,NG,NGA,566,NIG,nr,NI,NGR,234,NGA,NI,182,NGR,NGN,NIGERIA,2,Naira,566,Yes
163
+ Niue,Niué,NU,NIU,570,NIU,xh, ,NZ,683,NIU,NE,183,NIU,NZD,NIUE,2,New Zealand Dollar,554,Associated with NZ
164
+ Norfolk Island,"Norfolk, Île",NF,NFK,574,NFK,nx,NF,AUS,672,NFK,NF,184,NFI,AUD,NORFOLK ISLAND,2,Australian Dollar,036,Territory of AU
165
+ Northern Mariana Islands,"Mariannes du Nord, Îles",MP,MNP,580,MRA,nw,MY,USA,1-670,NMI,CQ,185,NMA,USD,NORTHERN MARIANA ISLANDS,2,US Dollar,840,Commonwealth of US
166
+ Norway,Norvège,NO,NOR,578,NOR,no,NO,N,47,NOR,NO,186,NOR,NOK,NORWAY,2,Norwegian Krone,578,Yes
167
+ Oman,Oman,OM,OMN,512,OMA,mk,OM, ,968,OMA,MU,187,OMA,OMR,OMAN,3,Rial Omani,512,Yes
168
+ Pakistan,Pakistan,PK,PAK,586,PAK,pk,PK,PK,92,PAK,PK,188,PAK,PKR,PAKISTAN,2,Pakistan Rupee,586,Yes
169
+ Palau,Palaos,PW,PLW,585,PLW,pw, , ,680,PLW,PS,189,PLW,USD,PALAU,2,US Dollar,840,Yes
170
+ "Palestine, State of","Palestine, État de",PS,PSE,275, ,"gz,wj", , ,970,PLE,"GZ,WE",91 267,PLE,,"PALESTINE, STATE OF",,No universal currency,,In contention
171
+ Panama,Panama,PA,PAN,591,PNR,pn,PM,PA,507,PAN,PM,191,PAN,USD,PANAMA,2,US Dollar,840,Yes
172
+ Papua New Guinea,Papouasie-Nouvelle-Guinée,PG,PNG,598,PNG,pp,NG,PNG,675,PNG,PP,192,PNG,PGK,PAPUA NEW GUINEA,2,Kina,598,Yes
173
+ Paraguay,Paraguay,PY,PRY,600,PRG,py,PY,PY,595,PAR,PA,194,PAR,PYG,PARAGUAY,0,Guarani,600,Yes
174
+ Peru,Pérou,PE,PER,604,PRU,pe,PR,PE,51,PER,PE,195,PER,PEN,PERU,2,Nuevo Sol,604,Yes
175
+ Philippines,Philippines,PH,PHL,608,PHL,ph,PH,RP,63,PHI,RP,196,PHI,PHP,PHILIPPINES,2,Philippine Peso,608,Yes
176
+ Pitcairn,Pitcairn,PN,PCN,612,PTC,pc,PT, ,870,PCN,PC,197, ,NZD,PITCAIRN,2,New Zealand Dollar,554,Territory of GB
177
+ Poland,Pologne,PL,POL,616,POL,pl,PL,PL,48,POL,PL,198,POL,PLN,POLAND,2,Zloty,985,Yes
178
+ Portugal,Portugal,PT,PRT,620,POR,po,PO,P,351,POR,PO,199,POR,EUR,PORTUGAL,2,Euro,978,Yes
179
+ Puerto Rico,Porto Rico,PR,PRI,630,PTR,pr,PU,USA,1,PUR,RQ,200,PUR,USD,PUERTO RICO,2,US Dollar,840,Commonwealth of US
180
+ Qatar,Qatar,QA,QAT,634,QAT,qa,QT,Q,974,QAT,QA,201,QAT,QAR,QATAR,2,Qatari Rial,634,Yes
181
+ Romania,Roumanie,RO,ROU,642,ROU,rm,RO,RO,40,ROU,RO,203,ROU,RON,ROMANIA,2,New Romanian Leu,946,Yes
182
+ Russian Federation,"Russie, Fédération de",RU,RUS,643,RUS,ru,RS,RUS,7,RUS,RS,204,RUS,RUB,RUSSIAN FEDERATION,2,Russian Ruble,643,Yes
183
+ Rwanda,Rwanda,RW,RWA,646,RRW,rw,RW,RWA,250,RWA,RW,205,RWA,RWF,RWANDA,0,Rwanda Franc,646,Yes
184
+ Réunion,Réunion,RE,REU,638,REU,re,RE,F,262,REU,RE,206,REU,EUR,RÉUNION,2,Euro,978,Part of FR
185
+ Saint Barthélemy,Saint-Barthélemy,BL,BLM,652, ,sc, , ,590, ,TB,, ,EUR,SAINT BARTHÉLEMY,2,Euro,978,Part of FR
186
+ "Saint Helena, Ascension and Tristan da Cunha","Sainte-Hélène, Ascension et Tristan da Cunha",SH,SHN,654,SHN,xj,HE, ,290 n,SHN,SH,207,HEL,SHP,"SAINT HELENA, ASCENSION AND TRISTAN DA CUNHA",2,Saint Helena Pound,654,Territory of GB
187
+ Saint Kitts and Nevis,Saint-Kitts-Et-Nevis,KN,KNA,659,KNA,xd,AT, ,1-869,SKN,SC,208,SKN,XCD,SAINT KITTS AND NEVIS,2,East Caribbean Dollar,951,Yes
188
+ Saint Lucia,Sainte-Lucie,LC,LCA,662,LCA,xk,LC,WL,1-758,LCA,ST,209,LCA,XCD,SAINT LUCIA,2,East Caribbean Dollar,951,Yes
189
+ Saint Martin (French part),Saint-Martin(partie Française),MF,MAF,663, ,st, , ,590, ,RN,, ,EUR,SAINT MARTIN (FRENCH PART),2,Euro,978,Part of FR
190
+ Saint Pierre and Miquelon,Saint-Pierre-Et-Miquelon,PM,SPM,666,SPM,xl,FP,F,508,SPM,SB,210,SPM,EUR,SAINT PIERRE AND MIQUELON,2,Euro,978,Part of FR
191
+ Saint Vincent and the Grenadines,Saint-Vincent-Et-Les Grenadines,VC,VCT,670,VCT,xm,VG,WV,1-784,VIN,VC,211,VIN,XCD,SAINT VINCENT AND THE GRENADINES,2,East Caribbean Dollar,951,Yes
192
+ Samoa,Samoa,WS,WSM,882,SMO,ws,ZM,WS,685,SAM,WS,212,SAM,WST,SAMOA,2,Tala,882,Yes
193
+ San Marino,Saint-Marin,SM,SMR,674,SMR,sm, ,RSM,378,SMR,SM,213,SMR,EUR,SAN MARINO,2,Euro,978,Yes
194
+ Sao Tome and Principe,Sao Tomé-Et-Principe,ST,STP,678,STP,sf,TP, ,239,STP,TP,214,STP,STD,SAO TOME AND PRINCIPE,2,Dobra,678,Yes
195
+ Saudi Arabia,Arabie Saoudite,SA,SAU,682,ARS,su,SD,SA,966,KSA,SA,215,KSA,SAR,SAUDI ARABIA,2,Saudi Riyal,682,Yes
196
+ Senegal,Sénégal,SN,SEN,686,SEN,sg,SG,SN,221,SEN,SG,217,SEN,XOF,SENEGAL,0,CFA Franc BCEAO,952,Yes
197
+ Serbia,Serbie,RS,SRB,688,SRB,rb,YG,SRB,381 p,SRB,"RI,KV",2648,SRB,RSD,SERBIA,2,Serbian Dinar,941,Yes
198
+ Seychelles,Seychelles,SC,SYC,690,SEY,se,SC,SY,248,SEY,SE,220,SEY,SCR,SEYCHELLES,2,Seychelles Rupee,690,Yes
199
+ Sierra Leone,Sierra Leone,SL,SLE,694,SRL,sl,SL,WAL,232,SLE,SL,221,SLE,SLL,SIERRA LEONE,2,Leone,694,Yes
200
+ Singapore,Singapour,SG,SGP,702,SNG,si,SR,SGP,65,SIN,SN,222,SIN,SGD,SINGAPORE,2,Singapore Dollar,702,Yes
201
+ Sint Maarten (Dutch part),Saint-Martin (Partie Néerlandaise),SX,SXM,534,,sn,,,1-721,,NN,,,ANG,SINT MAARTEN (DUTCH PART),2,Netherlands Antillean Guilder,532,Part of NL
202
+ Slovakia,Slovaquie,SK,SVK,703,SVK,xo,SQ,SK,421,SVK,LO,223,SVK,EUR,SLOVAKIA,2,Euro,978,Yes
203
+ Slovenia,Slovénie,SI,SVN,705,SVN,xv,LJ,SLO,386,SVN,SI,224,SLO,EUR,SLOVENIA,2,Euro,978,Yes
204
+ Solomon Islands,"Salomon, Îles",SB,SLB,090,SLM,bp,SO, ,677,SOL,BP,225,SOL,SBD,SOLOMON ISLANDS,2,Solomon Islands Dollar,090,Yes
205
+ Somalia,Somalie,SO,SOM,706,SOM,so,SI,SO,252,SOM,SO,226,SOM,SOS,SOMALIA,2,Somali Shilling,706,Yes
206
+ South Africa,Afrique du Sud,ZA,ZAF,710,AFS,sa,ZA,ZA,27,RSA,SF,227,RSA,ZAR,SOUTH AFRICA,2,Rand,710,Yes
207
+ South Georgia and the South Sandwich Islands,Géorgie du Sud-Et-Les Îles Sandwich du Sud,GS,SGS,239, ,xs, , ,500,,SX,228, ,,SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS,,No universal currency,,Territory of GB
208
+ South Sudan,Soudan du Sud,SS,SSD,728,SSD,sd,,,211,,OD,,,SSP,SOUTH SUDAN,2,South Sudanese Pound,728,Yes
209
+ Spain,Espagne,ES,ESP,724,E,sp,SP,E,34,ESP,SP,229,ESP,EUR,SPAIN,2,Euro,978,Yes
210
+ Sri Lanka,Sri Lanka,LK,LKA,144,CLN,ce,SB,CL,94,SRI,CE,231,SRI,LKR,SRI LANKA,2,Sri Lanka Rupee,144,Yes
211
+ Sudan,Soudan,SD,SDN,729,SDN,sj,SU,SUD,249,SUD,SU,40764,SUD,SDG,SUDAN,2,Sudanese Pound,938,Yes
212
+ Suriname,Suriname,SR,SUR,740,SUR,sr,SM,SME,597,SUR,NS,233,SUR,SRD,SURINAME,2,Surinam Dollar,968,Yes
213
+ Svalbard and Jan Mayen,Svalbard et Île Jan Mayen,SJ,SJM,744,NOR, ,SZ, ,47,,"SV,JN",234, ,NOK,SVALBARD AND JAN MAYEN,2,Norwegian Krone,578,Territory of NO
214
+ Swaziland,Swaziland,SZ,SWZ,748,SWZ,sq,SV,SD,268,SWZ,WZ,235,SWZ,SZL,SWAZILAND,2,Lilangeni,748,Yes
215
+ Sweden,Suède,SE,SWE,752,S,sw,SN,S,46,SWE,SW,236,SWE,SEK,SWEDEN,2,Swedish Krona,752,Yes
216
+ Switzerland,Suisse,CH,CHE,756,SUI,sz,SW,CH,41,SUI,SZ,237,SUI,CHF,SWITZERLAND,2,Swiss Franc,756,Yes
217
+ Syrian Arab Republic,"Syrienne, République Arabe",SY,SYR,760,SYR,sy,SY,SYR,963,SYR,SY,238,SYR,SYP,SYRIAN ARAB REPUBLIC,2,Syrian Pound,760,Yes
218
+ "Taiwan, Province of China","Taïwan, Province de Chine",TW,TWN,158, ,ch, ,RC,886,TPE,TW,925,TPE,TWD,"TAIWAN, PROVINCE OF CHINA",2,New Taiwan Dollar,901,Yes
219
+ Tajikistan,Tadjikistan,TJ,TJK,762,TJK,ta,TA,TJ,992,TJK,TI,239,TJK,TJS,TAJIKISTAN,2,Somoni,972,Yes
220
+ "Tanzania, United Republic of","Tanzanie, République-Unie de",TZ,TZA,834,TZA,tz,TN,EAT,255,TAN,TZ,257,TAN,TZS,"TANZANIA, UNITED REPUBLIC OF",2,Tanzanian Shilling,834,Yes
221
+ Thailand,Thaïlande,TH,THA,764,THA,th,TH,T,66,THA,TH,240,THA,THB,THAILAND,2,Baht,764,Yes
222
+ Timor-Leste,Timor-Leste,TL,TLS,626,TLS,em,TM, ,670,TLS,TT,242,TLS,USD,TIMOR-LESTE,2,US Dollar,840,Yes
223
+ Togo,Togo,TG,TGO,768,TGO,tg,TG,TG,228,TOG,TO,243,TOG,XOF,TOGO,0,CFA Franc BCEAO,952,Yes
224
+ Tokelau,Tokelau,TK,TKL,772,TKL,tl,TK,NZ,690,TKL,TL,244, ,NZD,TOKELAU,2,New Zealand Dollar,554,Territory of NZ
225
+ Tonga,Tonga,TO,TON,776,TON,to,TO, ,676,TGA,TN,245,TGA,TOP,TONGA,2,Pa’anga,776,Yes
226
+ Trinidad and Tobago,Trinité-Et-Tobago,TT,TTO,780,TRD,tr,TD,TT,1-868,TRI,TD,246,TRI,TTD,TRINIDAD AND TOBAGO,2,Trinidad and Tobago Dollar,780,Yes
227
+ Tunisia,Tunisie,TN,TUN,788,TUN,ti,TS,TN,216,TUN,TS,248,TUN,TND,TUNISIA,3,Tunisian Dinar,788,Yes
228
+ Turkey,Turquie,TR,TUR,792,TUR,tu,TU,TR,90,TUR,TU,249,TUR,TRY,TURKEY,2,Turkish Lira,949,Yes
229
+ Turkmenistan,Turkménistan,TM,TKM,795,TKM,tk,TR,TM,993,TKM,TX,250,TKM,TMT,TURKMENISTAN,2,Turkmenistan New Manat,934,Yes
230
+ Turks and Caicos Islands,"Turks-Et-Caïcos, Îles",TC,TCA,796,TCA,tc,TI, ,1-649,TCA,TK,251,TKS,USD,TURKS AND CAICOS ISLANDS,2,US Dollar,840,Territory of GB
231
+ Tuvalu,Tuvalu,TV,TUV,798,TUV,tv,TV, ,688,TUV,TV,252,TUV,AUD,TUVALU,2,Australian Dollar,036,Yes
232
+ Uganda,Ouganda,UG,UGA,800,UGA,ug,UG,EAU,256,UGA,UG,253,UGA,UGX,UGANDA,0,Uganda Shilling,800,Yes
233
+ Ukraine,Ukraine,UA,UKR,804,UKR,un,UR,UA,380,UKR,UP,254,UKR,UAH,UKRAINE,2,Hryvnia,980,Yes
234
+ United Arab Emirates,Émirats Arabes Unis,AE,ARE,784,UAE,ts,ER, ,971,UAE,AE,255,UAE,AED,UNITED ARAB EMIRATES,2,UAE Dirham,784,Yes
235
+ United Kingdom,Royaume-Uni,GB,GBR,826,G,xxk,UK,GB,44,"ENG,NIR,SCO,WAL",UK,256,GBR,GBP,UNITED KINGDOM,2,Pound Sterling,826,Yes
236
+ United States,États-Unis,US,USA,840,USA,xxu,US,USA,1,USA,US,259,USA,USD,UNITED STATES,2,US Dollar,840,Yes
237
+ United States Minor Outlying Islands,Îles Mineures Éloignées des États-Unis,UM,UMI,581, ,"ji,xf,wk,uc,up", ,USA, ,,"FQ,HQ,DQ,JQ,KQ,MQ,BQ,LQ,WQ",, ,USD,UNITED STATES MINOR OUTLYING ISLANDS,2,US Dollar,840,Territories of US
238
+ Uruguay,Uruguay,UY,URY,858,URG,uy,UY,ROU,598,URU,UY,260,URU,UYU,URUGUAY,2,Peso Uruguayo,858,Yes
239
+ Uzbekistan,Ouzbékistan,UZ,UZB,860,UZB,uz,UZ,UZ,998,UZB,UZ,261,UZB,UZS,UZBEKISTAN,2,Uzbekistan Sum,860,Yes
240
+ Vanuatu,Vanuatu,VU,VUT,548,VUT,nn,NV, ,678,VAN,NH,262,VAN,VUV,VANUATU,0,Vatu,548,Yes
241
+ "Venezuela, Bolivarian Republic of","Venezuela, République Bolivarienne du",VE,VEN,862,VEN,ve,VN,YV,58,VEN,VE,263,VEN,VEF,"VENEZUELA, BOLIVARIAN REPUBLIC OF",2,Bolivar,937,Yes
242
+ Viet Nam,Viet Nam,VN,VNM,704,VTN,vm,VS,VN,84,VIE,VM,264,VIE,VND,VIET NAM,0,Dong,704,Yes
243
+ "Virgin Islands, British",Îles Vierges Britanniques,VG,VGB,092,VRG,vb,VI,BVI,1-284,VGB,VI,39,IVB,USD,VIRGIN ISLANDS (BRITISH),2,US Dollar,840,Territory of GB
244
+ "Virgin Islands, U.S.",Îles Vierges des États-Unis,VI,VIR,850,VIR,vi,VI,USA,1-340,VIR,VQ,258,ISV,USD,VIRGIN ISLANDS (US),2,US Dollar,840,Territory of US
245
+ Wallis and Futuna,Wallis et Futuna,WF,WLF,876,WAL,wf,FW,F,681,WLF,WF,266,WAF,XPF,WALLIS AND FUTUNA,0,CFP Franc,953,Territory of FR
246
+ Western Sahara,Sahara Occidental,EH,ESH,732,AOE,ss, , ,212,SAH,WI,268, ,MAD,WESTERN SAHARA,2,Moroccan Dirham,504,In contention
247
+ Yemen,Yémen,YE,YEM,887,YEM,ye,YE,YAR,967,YEM,YM,269,YEM,YER,YEMEN,2,Yemeni Rial,886,Yes
248
+ Zambia,Zambie,ZM,ZMB,894,ZMB,za,ZB,Z,260,ZAM,ZA,270,ZAM,ZMW,ZAMBIA,2,Zambian Kwacha,967,Yes
249
+ Zimbabwe,Zimbabwe,ZW,ZWE,716,ZWE,rh,ZW,ZW,263,ZIM,ZI,271,ZIM,ZWL,ZIMBABWE,2,Zimbabwe Dollar,932,Yes
250
+ Åland Islands,"Åland, Îles",AX,ALA,248, , , ,FIN,358,ALD, ,1242, ,EUR,ÅLAND ISLANDS,2,Euro,978,Part of FI
@@ -0,0 +1,142 @@
1
+ {
2
+ "name": "country-codes",
3
+ "title": "Comprehensive country codes: ISO 3166, ITU, ISO 4217 currency codes and many more",
4
+ "format": "csv",
5
+ "datapackage_version": "1.0-beta.3",
6
+ "licenses": [
7
+ {
8
+ "id": "odc-pddl",
9
+ "name": "Public Domain Dedication and License",
10
+ "version": "1.0",
11
+ "url": "http://opendatacommons.org/licenses/pddl/1.0/"
12
+ }
13
+ ],
14
+ "sources": [
15
+ {
16
+ "name": "International Organization for Standardization",
17
+ "web": "http://www.iso.org/iso/country_codes/iso_3166_code_lists.htm"
18
+ },
19
+ {
20
+ "name": "SIX Interbank Clearing Ltd (on behalf of ISO)",
21
+ "web": "http://www.currency-iso.org/dam/downloads/dl_iso_table_a1.xls"
22
+ },
23
+ {
24
+ "name": "Statoids",
25
+ "web": "http://www.statoids.com/wab.html"
26
+ }
27
+ ],
28
+ "resources": [
29
+ {
30
+ "url": "https://raw.github.com/datasets/country-codes/master/data/country-codes.csv",
31
+ "path": "data/country-codes.csv",
32
+ "schema": {
33
+ "fields": [
34
+ {
35
+ "name": "name",
36
+ "description": "Country's official English short name",
37
+ "type": "string"
38
+ },
39
+ {
40
+ "name": "name_fr",
41
+ "description": "Country's offical French short name",
42
+ "type": "string"
43
+ },
44
+ {
45
+ "name": "ISO3166-1-Alpha-2",
46
+ "description": "Alpha-2 codes from ISO 3166-1",
47
+ "type": "string"
48
+ },
49
+ {
50
+ "name": "ISO3166-1-Alpha-3",
51
+ "description": "Alpha-3 codes from ISO 3166-1 (synonymous with World Bank Codes)",
52
+ "type": "string"
53
+ },
54
+ {
55
+ "name": "ISO3166-1-numeric",
56
+ "description": "Numeric codes from ISO 3166-1 (synonymous with UN Statistics M49 Codes)",
57
+ "type": "integer"
58
+ },
59
+ {
60
+ "name": "ITU",
61
+ "description": "Codes assigned by the International Telecommunications Union",
62
+ "type": "string"
63
+ },
64
+ {
65
+ "name": "MARC",
66
+ "description": "MAchine-Readable Cataloging codes from the Library of Congress",
67
+ "type": "string"
68
+ },
69
+ {
70
+ "name": "WMO",
71
+ "description": "Country abbreviations by the World Meteorological Organization",
72
+ "type": "string"
73
+ },
74
+ {
75
+ "name": "DS",
76
+ "description": "Distinguishing signs of vehicles in international traffic",
77
+ "type": "string"
78
+ },
79
+ {
80
+ "name": "Dial",
81
+ "description": "Country code from ITU-T recommendation E.164, sometimes followed by area code",
82
+ "type": "string"
83
+ },
84
+ {
85
+ "name": "FIFA",
86
+ "description": "Codes assigned by the Fédération Internationale de Football Association",
87
+ "type": "string"
88
+ },
89
+ {
90
+ "name": "FIPS",
91
+ "description": "Codes from the U.S. standard FIPS PUB 10-4",
92
+ "type": "string"
93
+ },
94
+ {
95
+ "name": "GAUL",
96
+ "description": "Global Administrative Unit Layers from the Food and Agriculture Organization",
97
+ "type": "integer"
98
+ },
99
+ {
100
+ "name": "IOC",
101
+ "description": "Codes assigned by the International Olympics Committee",
102
+ "type": "string"
103
+ },
104
+ {
105
+ "name": "currency_alphabetic_code",
106
+ "description": "ISO 4217 currency alphabetic code",
107
+ "type": "string"
108
+ },
109
+ {
110
+ "name": "currency_country_name",
111
+ "description": "ISO 4217 country name",
112
+ "type": "string"
113
+ },
114
+ {
115
+ "name": "currency_minor_unit",
116
+ "description": "ISO 4217 currency number of minor units",
117
+ "type": "integer"
118
+ },
119
+ {
120
+ "name": "currency_name",
121
+ "description": "ISO 4217 currency name",
122
+ "type": "string"
123
+ },
124
+ {
125
+ "name": "currency_numeric_code",
126
+ "description": "ISO 4217 currency numeric code",
127
+ "type": "integer"
128
+ },
129
+ {
130
+ "name": "is_independent",
131
+ "description": "Country status, based on the CIA World Factbook",
132
+ "type": "string"
133
+ }
134
+ ]
135
+ }
136
+ }
137
+ ],
138
+ "maintainers":[{
139
+ "name": "Evan Wheeler",
140
+ "web": "https://github.com/datasets/country-codes"
141
+ }]
142
+ }
@@ -0,0 +1,370 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+ # vim: ai ts=4 sts=4 et sw=4
4
+ import codecs
5
+ import urllib
6
+ import argparse
7
+ import json
8
+ import operator
9
+ import collections
10
+
11
+ from lxml import html
12
+ from lxml import etree
13
+
14
+ # some ANSI colors, etc
15
+ BLUE = '\033[94m'
16
+ GREEN = '\033[92m'
17
+ YELLOW = '\033[93m'
18
+ RED = '\033[91m'
19
+ BOLD = '\033[1m'
20
+ ENDC = '\033[0m'
21
+
22
+
23
+ def print_info(string):
24
+ print GREEN + string + ENDC
25
+
26
+
27
+ def print_warn(string):
28
+ print YELLOW + string + ENDC
29
+
30
+
31
+ def print_error(string):
32
+ print RED + string + ENDC
33
+
34
+
35
+ def process_statoids_row(tr):
36
+ row = []
37
+ for td in tr.iterchildren():
38
+ if len(td.keys()) > 0:
39
+ if td.get('colspan') is not None:
40
+ # if a cell is taking up more than one column,
41
+ # append the same number of blanks to the row
42
+ assert td.get('colspan').isdigit()
43
+ for col in xrange(int(td.get('colspan'))):
44
+ row.append('')
45
+ continue
46
+ if len(td.getchildren()) == 1:
47
+ if td.find('.//br') is not None:
48
+ if len(td.getchildren()) == 1:
49
+ if td.getchildren()[0].tag == 'br':
50
+ td.text = td.text + " " + td.getchildren()[0].tail
51
+ row.append(td.text)
52
+ continue
53
+ if td.find("code") is not None:
54
+ # some cells contain more than one code,
55
+ # so append a list also containing the code
56
+ # that appears after the child element (<br>)
57
+ if len(td.find("code").getchildren()) > 0:
58
+ if td.find('.//br') is not None:
59
+ row.append(td.find('code').text + ',' + td.find('.//br').tail)
60
+ continue
61
+ if td.find('.//a') is not None:
62
+ anchor = td.find('.//a')
63
+ # UK has 4 FIFA codes
64
+ if row[1] == "GB":
65
+ assert anchor.text == "1"
66
+ row.append("ENG,NIR,SCO,WAL")
67
+ continue
68
+ # MARC treats United States Minor Outlying Islands
69
+ # as five countries
70
+ if row[1] == "UM":
71
+ assert anchor.text == "b"
72
+ row.append("ji,xf,wk,uc,up")
73
+ continue
74
+ # some cells contain anchor to footnote,
75
+ # so append only the content of the code element
76
+ row.append(td.find("code").text)
77
+ continue
78
+ else:
79
+ if td.find('.//a') is not None:
80
+ anchor = td.find('.//a')
81
+ # FIPS treats United States Minor Outlying Islands
82
+ # as nine countries
83
+ if len(row) > 1 and row[1] == "UM":
84
+ assert anchor.text == "a"
85
+ row.append("FQ,HQ,DQ,JQ,KQ,MQ,BQ,LQ,WQ")
86
+ continue
87
+ row.append(td.text_content())
88
+ return row
89
+
90
+ def clean_line(line):
91
+ try:
92
+ line = line.decode('utf8')
93
+ line = line.rstrip()
94
+ if ';' in line:
95
+ semi = line.index(';')
96
+ name = line[:semi]
97
+ alpha2 = line[semi + 1:]
98
+ return (name, alpha2)
99
+ return (None, None)
100
+ except UnicodeDecodeError:
101
+ print_warn('Unable to decode country name: %s' % line)
102
+
103
+ def capitalize_country_name(name):
104
+ # replace all-caps name with capitalized country name
105
+ cap_list = []
106
+ always_lower = ['AND', 'THE', 'OF', 'PART', 'DA', 'DE', 'ET', 'DU', 'DES',
107
+ 'LA']
108
+ for w in name.split():
109
+ if w == 'MCDONALD':
110
+ cap_list.append('McDonald')
111
+ if w.find('.') > 0:
112
+ cap_list.append(w.upper())
113
+ continue
114
+ if w.find('\'') > 0:
115
+ # d'Ivoire instead of D'ivoire
116
+ s = w.split('\'')
117
+ if len(s[0]) == 1:
118
+ cap_list.append(s[0].lower() + '\'' + s[1].capitalize())
119
+ continue
120
+ if w.find('-') > 0:
121
+ # Timor-Leste instead of Timor-leste
122
+ cap_list.append('-'.join([s.capitalize() for s in w.split('-')]))
123
+ continue
124
+
125
+ if w.startswith('('):
126
+ w = w.replace('(', '')
127
+ if w in always_lower:
128
+ w = w.lower()
129
+ else:
130
+ w = w.capitalize()
131
+ cap_list.append('(' + w)
132
+ continue
133
+
134
+ if w[-1] == ')':
135
+ w = w.replace(')', '')
136
+ if w in always_lower:
137
+ w = w.lower()
138
+ else:
139
+ w = w.capitalize()
140
+ cap_list.append(w + ')')
141
+ continue
142
+
143
+ if w in always_lower:
144
+ cap_list.append(w.lower())
145
+ continue
146
+ cap_list.append(w.capitalize())
147
+
148
+ capitalized = " ".join(cap_list)
149
+ return capitalized
150
+
151
+
152
+ def get_currency_data(country_info, en_names):
153
+ # fetch iso currency codes
154
+ currency_url = "http://www.currency-iso.org/dam/downloads/table_a1.xml"
155
+ print_info('Fetching currency codes...')
156
+ currencies_xml_str = urllib.urlopen(currency_url).read()
157
+ currencies = etree.fromstring(currencies_xml_str)
158
+
159
+ # map source's tag names to our property names
160
+ currency_tag_map = {
161
+ u"CtryNm": u"currency_country_name",
162
+ u"CcyNm": u"currency_name",
163
+ u"Ccy": u"currency_alphabetic_code",
164
+ u"CcyNbr": u"currency_numeric_code",
165
+ u"CcyMnrUnts": u"currency_minor_unit",
166
+ u"AddtlInf": u"currency_additional_info"
167
+ }
168
+ # reconcile country names, add entries for non-country-based currencies
169
+ currency_country_name_map = {
170
+ u"MACEDONIA, THE FORMER \nYUGOSLAV REPUBLIC OF": "MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF",
171
+ u"SAINT HELENA, ASCENSION AND \nTRISTAN DA CUNHA": "SAINT HELENA, ASCENSION AND TRISTAN DA CUNHA",
172
+ u"CONGO, THE DEMOCRATIC REPUBLIC OF": "CONGO, THE DEMOCRATIC REPUBLIC OF THE",
173
+ u"HEARD ISLAND AND McDONALD ISLANDS": "HEARD ISLAND AND MCDONALD ISLANDS",
174
+ u"KOREA, DEMOCRATIC PEOPLE’S REPUBLIC OF": "KOREA, DEMOCRATIC PEOPLE'S REPUBLIC OF",
175
+ u"LAO PEOPLE’S DEMOCRATIC REPUBLIC": "LAO PEOPLE'S DEMOCRATIC REPUBLIC",
176
+ u"SERBIA ": "SERBIA",
177
+ u"PALESTINIAN TERRITORY, OCCUPIED": "PALESTINE, STATE OF",
178
+ u"Vatican City State (HOLY SEE)": "HOLY SEE (VATICAN CITY STATE)",
179
+ u"VIRGIN ISLANDS (BRITISH)": "VIRGIN ISLANDS, BRITISH",
180
+ u"VIRGIN ISLANDS (US)": "VIRGIN ISLANDS, U.S.",
181
+ u"MEMBER COUNTRIES OF THE AFRICAN DEVELOPMENT BANK GROUP": None,
182
+ u"INTERNATIONAL MONETARY FUND (IMF)": None,
183
+ u"SISTEMA UNITARIO DE COMPENSACION REGIONAL DE PAGOS \"SUCRE\"": None,
184
+ u"EUROPEAN UNION": None,
185
+ u"ZZ01_Bond Markets Unit European_EURCO": None,
186
+ u"ZZ02_Bond Markets Unit European_EMU-6": None,
187
+ u"ZZ03_Bond Markets Unit European_EUA-9": None,
188
+ u"ZZ04_Bond Markets Unit European_EUA-17": None,
189
+ u"ZZ05_UIC-Franc": None,
190
+ u"ZZ06_Testing_Code": None,
191
+ u"ZZ07_No_Currency": None,
192
+ u"ZZ08_Gold": None,
193
+ u"ZZ09_Palladium": None,
194
+ u"ZZ10_Platinum": None,
195
+ u"ZZ11_Silver": None,
196
+ }
197
+
198
+ def process_element(country):
199
+ currency_dict = {}
200
+ for currency_tag in country.iterchildren():
201
+ # ignore newly added additional info field
202
+ if currency_tag_map[currency_tag.tag] == "currency_additional_info":
203
+ break
204
+ # skip 'same day', 'next day', etc variations
205
+ elif (currency_tag_map[currency_tag.tag] == "currency_name") and (len(currency_tag.items()) > 0):
206
+ if currency_tag.items()[0][0] == 'IsFund':
207
+ break
208
+ else:
209
+ currency_dict.update({
210
+ currency_tag_map[currency_tag.tag]: currency_tag.text})
211
+ currency_alpha2 = None
212
+ # remove random line breaks, etc
213
+ currency_name = currency_dict['currency_country_name'].replace(u'\xa0', u'').replace(u'\n', u'').replace(u'\r', u'')
214
+ if currency_name is not None:
215
+ # replace name with line breaks, etc removed
216
+ currency_dict['currency_country_name'] = currency_name
217
+ try:
218
+ currency_alpha2 = en_names[currency_name]
219
+ except KeyError:
220
+ currency_alpha2 = en_names.get(
221
+ currency_country_name_map.get(currency_name))
222
+
223
+ if currency_alpha2:
224
+ country_info[currency_alpha2].update(currency_dict)
225
+ else:
226
+ if currency_name not in currency_country_name_map:
227
+ print_warn('Failed to match currency data for country: "%s"'
228
+ % currency_name)
229
+ return
230
+
231
+ for iso_currency_table in currencies.iterchildren():
232
+ for country in iso_currency_table.iterchildren():
233
+ process_element(country)
234
+
235
+ return country_info
236
+
237
+ def fetch_and_write(options):
238
+ # fetch ISO short names in English and French
239
+ print_info('Fetching English country names and codes...')
240
+ iso_names_en = urllib.urlretrieve('http://www.iso.org/iso/list-en1-semic-3.txt')
241
+ print_info('Fetching French country names and codes...')
242
+ iso_names_fr = urllib.urlretrieve('http://www.iso.org/iso/list-fr1-semic.txt')
243
+
244
+ # dict for combining en and fr names
245
+ # {alpha2: {'name': en, 'name_fr': fr}}
246
+ iso_names = {}
247
+
248
+ # dict for looking up alpha2 from name
249
+ en_names = {}
250
+
251
+ # urllib.urlretrieve returns a tuple of (localfile, headers)
252
+ with open(iso_names_en[0], "rU") as fin:
253
+ for line in fin:
254
+ name, alpha2 = clean_line(line)
255
+ if name and alpha2:
256
+ iso_names.update({alpha2: {'name': name}})
257
+ en_names.update({name: alpha2})
258
+
259
+ with open(iso_names_fr[0], "rU") as fin:
260
+ for line in fin:
261
+ name, alpha2 = clean_line(line)
262
+ if name and alpha2:
263
+ if alpha2 in iso_names:
264
+ # alpha2 should be in iso_names because
265
+ # english was parsed first,
266
+ # so append french name to list
267
+ names = iso_names[alpha2]
268
+ names.update({'name_fr': name})
269
+ iso_names.update({alpha2: names})
270
+ else:
271
+ # hopefully this doesnt happen, but
272
+ # in case there was no english name,
273
+ # add french with a blank space where
274
+ # english should be
275
+ names = {'name': '', 'name_fr': name}
276
+ iso_names.update({alpha2: names})
277
+
278
+ # fetch content of statoids.com country code page
279
+ statoids_url = "http://www.statoids.com/wab.html"
280
+ print_info('Fetching other country codes...')
281
+ content = urllib.urlopen(statoids_url).read()
282
+ doc = html.fromstring(content)
283
+
284
+ # i dislike some of statoid's column names, so here i have renamed
285
+ # a few to be more descriptive
286
+ column_names = ["Entity", "ISO3166-1-Alpha-2", "ISO3166-1-Alpha-3",
287
+ "ISO3166-1-numeric", "ITU", "FIPS", "IOC", "FIFA", "DS",
288
+ "WMO", "GAUL", "MARC", "Dial", "is_independent"]
289
+ alpha2_key = "ISO3166-1-Alpha-2"
290
+
291
+ # comment out the preceding two lines and
292
+ # uncomment these lines to use statoids.com column names
293
+ """
294
+ column_names = []
295
+ alpha2_key = 'A-2'
296
+ for tr in doc.find_class('hd'):
297
+ for th in tr.iterchildren():
298
+ column_names.append(th.text_content())
299
+ """
300
+
301
+ # dict to hold dicts of all table rows
302
+ table_rows = {}
303
+
304
+ # the country code info is in a table where the trs have
305
+ # alternating classes of `e` and `o`
306
+ # so fetch half of the rows and zip each row together
307
+ # with the corresponding column name
308
+ for tr in doc.find_class('e'):
309
+ row = process_statoids_row(tr)
310
+ row_dict = collections.OrderedDict(zip(column_names, row))
311
+ # statoids-assigned 'Entity' name is not really a standard
312
+ row_dict.pop('Entity')
313
+ table_rows.update({row_dict[alpha2_key]: row_dict})
314
+
315
+ # and again for the other half
316
+ for tr in doc.find_class('o'):
317
+ row = process_statoids_row(tr)
318
+ row_dict = collections.OrderedDict(zip(column_names, row))
319
+ # statoids-assigned 'Entity' name is not really a standard
320
+ row_dict.pop('Entity')
321
+ table_rows.update({row_dict[alpha2_key]: row_dict})
322
+
323
+ # dict to hold combined country info
324
+ country_info = {}
325
+ keyed_by = options.key
326
+
327
+ # iterate through all the table_rows
328
+ # TODO this assumes that statoids will have all of
329
+ # the items that are pulled from iso.org
330
+ for alpha2, info in table_rows.iteritems():
331
+ # ignore this crap that was parsed from other tables on the page
332
+ if alpha2 in ['', 'Codes', 'Codes Codes', 'Codes Codes Codes']:
333
+ continue
334
+ cinfo = info
335
+ # add iso.org's names to combined dict of this country's info
336
+ cinfo.update(iso_names[alpha2])
337
+ # replace all-caps name with capitalized country name
338
+ cinfo.update({'name': capitalize_country_name(cinfo['name'])})
339
+ cinfo.update({'name_fr': capitalize_country_name(cinfo['name_fr'])})
340
+ # add combined dict to global (pun intented) data structure
341
+ ckey = cinfo[keyed_by]
342
+ country_info.update({ckey: cinfo})
343
+
344
+ country_info = get_currency_data(country_info, en_names)
345
+
346
+ # reorganize data for export
347
+ if options.as_list:
348
+ # if exporting as list, sort by country name
349
+ country_info = sorted(country_info.values(), key=operator.itemgetter('name'))
350
+ # dump dict as json to file
351
+ output_filename = "data/country-codes.json"
352
+ if options.outfile:
353
+ output_filename = options.outfile
354
+ f = open(output_filename, mode='w')
355
+ stream = codecs.getwriter('utf8')(f)
356
+ json.dump(country_info, stream, ensure_ascii=False, indent=2, encoding='utf-8')
357
+ print_info('Saved country data to: %s' % output_filename)
358
+
359
+ if __name__ == "__main__":
360
+ parser = argparse.ArgumentParser(description='Fetch current ISO 3166 country codes and other standards and output as JSON file')
361
+ parser.add_argument("-o", "--output", dest="outfile", default="data/country-codes.json",
362
+ help="write data to OUTFILE", metavar="OUTFILE")
363
+ parser.add_argument("-l", "--list", dest="as_list", default=False, action="store_true",
364
+ help="export objects as a list of objects")
365
+ parser.add_argument("-k", "--key", dest="key", default="ISO3166-1-Alpha-2",
366
+ help="export objects as a dict of objects keyed by KEY", metavar="KEY")
367
+
368
+ args = parser.parse_args()
369
+
370
+ fetch_and_write(args)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+ # vim: ai ts=4 sts=4 et sw=4
4
+
5
+ import subprocess
6
+
7
+ subprocess.call('csvcut -c "name","name_fr","ISO3166-1-Alpha-2","ISO3166-1-Alpha-3","ISO3166-1-numeric","ITU","MARC","WMO","DS","Dial","FIFA","FIPS","GAUL","IOC","currency_alphabetic_code","currency_country_name","currency_minor_unit","currency_name","currency_numeric_code","is_independent" data/country-codes.csv > data/country-codes-reordered.csv', shell=True)
8
+ subprocess.call('mv data/country-codes-reordered.csv data/country-codes.csv', shell=True)
@@ -0,0 +1,2 @@
1
+ lxml==2.3
2
+ csvkit
@@ -91,6 +91,33 @@ def http_resource
91
91
  "name" => "standard",
92
92
  "url" => 'http://www.modeanlaytics.com/besquared/users',
93
93
 
94
+ 'schema' => {
95
+ 'fields' => [
96
+ {
97
+ 'name' => 'id',
98
+ 'type' => 'integer'
99
+ },
100
+ {
101
+ 'name' => 'first_name',
102
+ 'type' => 'string'
103
+ },
104
+ {
105
+ 'name' => 'last_name',
106
+ 'type' => 'string'
107
+ }
108
+ ],
109
+
110
+ 'primaryKey' => ['id']
111
+ }
112
+ }
113
+ end
114
+
115
+ def remote_resource
116
+ {
117
+ "name" => "country-codes",
118
+ "path" => "data/country-codes.csv",
119
+ "url" => "https://datahub.com/datasets/country-codes.csv",
120
+
94
121
  'schema' => {
95
122
  'fields' => [
96
123
  {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: data_package
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mode Analytics
@@ -139,8 +139,8 @@ files:
139
139
  - lib/data_package/schema.rb
140
140
  - lib/data_package/source.rb
141
141
  - lib/data_package/version.rb
142
- - spec/attr_helper_spec.rb
143
142
  - spec/attr_helpers/base_attr_spec.rb
143
+ - spec/attr_helpers/base_spec.rb
144
144
  - spec/attr_helpers/required_attr_spec.rb
145
145
  - spec/attr_helpers/serialization_spec.rb
146
146
  - spec/data_package/base_spec.rb
@@ -152,6 +152,12 @@ files:
152
152
  - spec/data_package/resource_spec.rb
153
153
  - spec/data_package/schema_spec.rb
154
154
  - spec/data_package/source_spec.rb
155
+ - spec/fixtures/country-codes/README.md
156
+ - spec/fixtures/country-codes/data/country-codes.csv
157
+ - spec/fixtures/country-codes/datapackage.json
158
+ - spec/fixtures/country-codes/scripts/get_countries_of_earth.py
159
+ - spec/fixtures/country-codes/scripts/reorder_columns.py
160
+ - spec/fixtures/country-codes/scripts/requirements.pip
155
161
  - spec/fixtures/package/datapackage.json
156
162
  - spec/fixtures/package/standard.csv
157
163
  - spec/fixtures/standard.csv
@@ -183,8 +189,8 @@ signing_key:
183
189
  specification_version: 4
184
190
  summary: Provides a set of classes for reading and writing data packages
185
191
  test_files:
186
- - spec/attr_helper_spec.rb
187
192
  - spec/attr_helpers/base_attr_spec.rb
193
+ - spec/attr_helpers/base_spec.rb
188
194
  - spec/attr_helpers/required_attr_spec.rb
189
195
  - spec/attr_helpers/serialization_spec.rb
190
196
  - spec/data_package/base_spec.rb
@@ -196,6 +202,12 @@ test_files:
196
202
  - spec/data_package/resource_spec.rb
197
203
  - spec/data_package/schema_spec.rb
198
204
  - spec/data_package/source_spec.rb
205
+ - spec/fixtures/country-codes/README.md
206
+ - spec/fixtures/country-codes/data/country-codes.csv
207
+ - spec/fixtures/country-codes/datapackage.json
208
+ - spec/fixtures/country-codes/scripts/get_countries_of_earth.py
209
+ - spec/fixtures/country-codes/scripts/reorder_columns.py
210
+ - spec/fixtures/country-codes/scripts/requirements.pip
199
211
  - spec/fixtures/package/datapackage.json
200
212
  - spec/fixtures/package/standard.csv
201
213
  - spec/fixtures/standard.csv