Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Encoding.default_external = 'utf-8'
- Encoding.default_internal = 'utf-8'
- path = ARGV.first
- # ids = [1, 3 ...]
- map = Hash.new
- def get_user_id(line)
- return (line.match /\d*$/).to_s
- end
- File.open(path, "r") do |f|
- f.each_line do |line|
- id = get_user_id(line)
- next if id.to_i == 0
- # next if id.to_i == 0 or not ids.include? id
- map[id] = Array.new if map[id].nil?
- map[id].push line
- puts "id: #{id}, length: #{map[id].length}" if map[id].length > 100
- end
- end
- puts map[34428]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement