Created
May 14, 2012 23:18
-
-
Save cgrusden/2698035 to your computer and use it in GitHub Desktop.
Latitude & Longitude average string lengths
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'fastercsv' | |
desc "Parse city data" | |
task "cities" do | |
headers = [:country_code, :ascii_name, :name, :state, :population, :lat, :long] | |
long_num, lat_num = [], [] | |
FasterCSV.foreach(File.join(File.dirname(__FILE__), "../../", "doc/us_cities.txt"), :headers => headers) do |row| | |
begin | |
lat_num << row[:lat].length | |
long_num << row[:long].length | |
rescue Exception => e | |
puts e.message | |
end | |
end | |
puts "Lat: #{lat_num.sort.uniq.inspect}" | |
puts "Long: #{long_num.sort.uniq.inspect}" | |
end | |
Output: | |
$ rake cities | |
Lat: [9, 10, 11] | |
Long: [11, 12] | |
So, US Cities Latitude numbers are in the 9-11 character length range and Longitude can be 11-12 characters long |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment