Skip to content

Instantly share code, notes, and snippets.

@bergman
Created August 5, 2015 11:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bergman/2f9cdfe052be9bf061e6 to your computer and use it in GitHub Desktop.
Save bergman/2f9cdfe052be9bf061e6 to your computer and use it in GitHub Desktop.
region code to region name
# curl -O "http://www.maxmind.com/download/geoip/misc/region_codes.csv"
import csv
region_lookup = {}
with open("region_codes.csv", "rb") as f:
reader = csv.reader(f, delimiter=",")
for i, row in enumerate(reader):
region_lookup[(row[0], row[1])] = row[2]
print "(US, CA): %s" % region_lookup[("US", "CA")]
print "(SE, 21): %s" % region_lookup[("SE", "21")]
print "(SE, 26): %s" % region_lookup[("SE", "26")]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment