to try these scripts, grab the free MaxMind database, unpack, and then edit the GeoLiteCity-Location.csv
file, removing the first (copyright) line.
on my laptop, the script which merely parses the data, converts to UTF-8, and then re-outputs as CSV again took 22.7 seconds of CPU time, while the script which additionally computes a SHA1 hash of the City, State (or other region), and Country took 28.7 seconds — only 6 seconds (26%) more.
you need Ruby 1.9.x, which is pretty much standard these days.