Skip to content

Instantly share code, notes, and snippets.

@jshawl
Created August 14, 2014 21:21
Show Gist options
  • Save jshawl/d0c9e14ef7a7b824c237 to your computer and use it in GitHub Desktop.
Save jshawl/d0c9e14ef7a7b824c237 to your computer and use it in GitHub Desktop.
require 'pry'
f = File.new("potter.csv", "r")
characters = []
f.each_line do |line|
each_character = line.chomp.split(",")
# binding.pry
mentions = each_character[0]
name = each_character[1]
if each_character[2]
house = each_character[2]
end
character = { :mentions => mentions,
:name => name,
:house => house
}
characters.push(character)
end
f.close
#puts characters
people_with_500_mentions = []
characters.each do |c|
if c[:mentions].to_i > 500
people_with_500_mentions << c
end
end
# puts people_with_500_mentions
names = []
characters.each do |c|
names << c[:name]
end
puts names
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment