views:

468

answers:

5

Is there a list of all the country names and their country code, such as US, AUS, UK, etc available which I can re-use in my code? Any plain text format e.g .txt, .csv, etc, or mysql database format will be fine.

If there can be an additional list of various regions in the world, such as Western Australia, North America, etc, and the country names/codes which go in that region, that would be even more helpful!

Thanks.

+5  A: 

Do you mean the ISO country codes? If yes, you can access them from databases. Maybe a quick query can sort you out.

duffymo
Indeed, how can i download them in a .txt or .csv format so they can be iterated over in my code?
Click Upvote
Try this: http://www.iso.org/iso/country_codes/iso_3166_databases.htm
duffymo
This is the link I want: http://www.iso.org/iso/list-en1-semic-3.txt . However I also need to group all the countries in 'Regions'. Is there any list which shows which continent or region a country belongs in?
Click Upvote
I'd muck around at the ISO site - they have all the scoop: http://www.iso.org/iso/home.htm. It's just a matter of finding it.
duffymo
A: 

The MaxMind GeoLite City list should have what you need.

Zed
There's a hidden gotcha with the GeoLite data you may need to be aware of: for the US and Canada the region field uses the ISO 3166-2 codes, but for all other countries they contain the FIPS-10 code values.
devstuff
+2  A: 

Check this

Amr ElGarhy
http://downloads.mysql.com/docs/world.sql.zip , that contains lists of countries as well as regions and continents they belong to
Click Upvote
Before you jump too deep into the list, it doesn't seem to contain countries like Serbia, or Montenegro (or Kosovo). This means it hasn't been updated for about five years now.
Zed
+1  A: 

The ISO codes mentioned by @duffymo are the best standard for country identifiers, but you may also want to look at the CLDR (Unicode Common Locale Data Repository) for hierarchical groupings like Regions.

Grab the current core archive, then look in common/supplemental/supplementalData.xml for the <territoryContainment> section. Note that the group identifiers do NOT correspond to the ISO country codes so your data store will have to handle both sets.

The CLDR supplemental data is also useful for answering related questions like the currencies and languages used in each region, time zone mappings, etc.

devstuff
A: 

At least inside the .NET Framework you can get the list by using the CultureInfo class. I remember barely a static function to get a list of all usable Cultures in the current environment.

BeowulfOF
Are all countries represented in the list of usable cultures?
Jonathan Leffler
As I remember every culture featured by the environment is availlable.But, cultures are not countries since some countries share same cultures.
BeowulfOF