Is there somewhere a Yaml or SQL insert list of all countries? [duplicate]
Possible Duplicate:
Where can I get a list of all countries/cities to populate a listbox?
I am looking for a script to create all the countries. Somebody knows an free ISO list i can easily use in Ruby?
I can find lists on google but I am not lucky with a yaml, csv or SQL inserts.
I am also very interested in al开发者_如何学运维l the cities in Spain.
EDIT: Countries + Country code
Edit2: Just interested in all cities of Spain.
I believe this is what you're looking for: http://download.geonames.org/export/dump/
I've just been searching for something similar myself and came across the World Countries API, which has a link there to a JSON file; http://www.geognos.com/api/en/countries/info/all.json.
You can also pull out info on a per country basis. Here's Spain; http://www.geognos.com/api/en/countries/info/ES.json
One really nice thing about this API is that it provides plenty more info than the basic country name/code. Here's an example of the output;
"ES": {
"Name": "Spain",
"Capital": {
"DLST": 1,
"TD": 1,
"Flg": 2,
"Name": "Madrid",
"GeoPt": [
40.24,
-3.41
]
},
"GeoRectangle": {
"West": -18.169641,
"East": 4.3153896,
"North": 43.791725,
"South": 27.638817
},
"SeqID": 66,
"GeoPt": [
40,
-4
],
"TelPref": "34",
"CountryCodes": {
"tld": "es",
"iso3": "ESP",
"iso2": "ES",
"fips": "SP",
"isoN": 724
},
"CountryInfo": "http://www.geognos.com/geo/en/cc/es.html"
},
I didn't look but perhaps they have cities per country info.
It's also a shame they don't include the native language(s) that are spoken but hey, it's still a good resource.
P.S. I know you asked for YAML, but you can use JSON in Ruby and there are also YAML/JSON converters about.
If CSV is okay, this is based on ISO 3166: http://www.guavastudios.com/downloads/countries/countries.csv
A great place to find this kind of data is http://thedatahub.org/ service. It supports a RESTful API.
精彩评论