2

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 all the cities in Spain.

EDIT: Countries + Country code

Edit2: Just interested in all cities of Spain.

Community
  • 1
  • 1
Michael Koper
  • 9,586
  • 7
  • 45
  • 59

4 Answers4

6

I believe this is what you're looking for: http://download.geonames.org/export/dump/

roberttdev
  • 42,762
  • 2
  • 20
  • 23
2

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.

mrcook
  • 640
  • 6
  • 11
1

If CSV is okay, this is based on ISO 3166: http://www.guavastudios.com/downloads/countries/countries.csv

Rafe Kettler
  • 75,757
  • 21
  • 156
  • 151
  • Thanks for your answer. Looks very nice but it is without country code. Sorry didnt mention that in the question. I updated my question – Michael Koper Mar 26 '11 at 19:41
0

A great place to find this kind of data is http://thedatahub.org/ service. It supports a RESTful API.

Aleksander Pohl
  • 1,675
  • 10
  • 14