问题
I find that I always find it useful to have a list of all Countries and their country codes. If someone provided it in multiple formats (eg: SQL, DDL, Xml, CSV, JSON, YAML...).
I've found sites that attempt to sell a list of countries but that seems crazy to me. Is there an open source project that I'm overlooking? If there isn't does anyone else see any usefulness of starting a project that maintains a list of countries and even something that attempts a region hierarchy?
There have been times where I have been wanting to retrieve the top 50 largest cities in a province located in Canada for example.
Ooh, maybe this could be a handy "cloud" computing service.
Thanks, I just want to make sure that I'm not over analyzing an issue that's had a trivial solution for ages.
[Edit]
Just realized that a community based regional allocation strategy might be a bit tricky. How would you deal with regions in conflict?
回答1:
HTML, XML, TXT and Access
http://www.iso.ch/iso/country_codes/iso_3166_code_lists.htm
回答2:
I occasionally find the Apendix of the CIA - World Fact Book useful.
回答3:
Also: http://www.ics.uci.edu/pub/websoft/wwwstat/country-codes.txt
回答4:
I assume what you want are the ISO 3166-1 2-alpha or 3-alpha codes, which are defined by ISO 3166-1. You can get various text and XML versions straight from ISO.org. This doesn't include any province, State, or city data, however.
EDIT: The UN/LOCODE site has a list of sublocations that sync up with ISO 3166-2 (ISO codes for provinces/States): http://www.unece.org/cefact/locode/service/sublocat.htm.
Also, UN/LOCODE has a location code list, which is a list of cities/towns by country: http://www.unece.org/cefact/locode/service/location.htm.
Finally, regarding the comment on regional differences/conflicts, ISO 3166-3 sort of approaches that, maintaining a list of prior names for locations.
回答5:
In Java, you can call java.util.Locale.getISOCountries(), which may help, depending on what you need.
A region hierarchy is more complex; I expect it cost Yahoo a lot to build that aspect of FireEagle.
There is a lot of information in the GNS country files at http://earth-info.nga.mil/gns/html/namefiles.htm - names, locations and other data for a very large number of places internationally.
回答6:
In mysql you can create country list with the help of Geonames API.
http://praveenravi.blogspot.in/2012/09/country-list-in-mysql.html
this link might be helpful
回答7:
Wikipedia has a list all country codes and their corresponding countries. I found it through a google search for "wikipedia country code".
来源:https://stackoverflow.com/questions/463459/does-there-exist-a-publicly-accessible-parsable-country-country-code-list