Skip to content

Instantly share code, notes, and snippets.

@tafsiri
Created September 3, 2012 22:57
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 tafsiri/3614426 to your computer and use it in GitHub Desktop.
Save tafsiri/3614426 to your computer and use it in GitHub Desktop.
biggest = {
:name => "",
:population => 0
}
lines_skipped = 0
File.foreach("data/allCountries.txt") do |line|
row = line.split("\t")
begin
if row.length == 19
pop = row[14].to_i
if pop > biggest[:population]
biggest[:population] = pop
biggest[:name] = row[1]
end
else
#something was wrong with that line in the input data
lines_skipped += 1
end
rescue
#something weird happened
lines_skipped += 1
end
end
puts lines_skipped
puts biggest.inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment