Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # coding: cp850
- require 'ap'
- f = open('./desktop/file.txt', &:read)
- lines = f.split(/\n\(\d+\)/).map{|l|l.strip.gsub("\xE2\x80\x8F","").split("\n").reject(&:"empty?") }
- data = {}
- lines[1..-1].each {|l|
- next if l[2].match(/^Y's Menettes/)
- month = l[0].scan(/\d+\/\d+$/)[0]
- person = l[2].split(", ")[0].split(" - ")[1].upcase
- data[person] = [] if data[person].nil?
- data[person] << month + " - " + l[2].split(", ")[1]
- }
- data = data.to_a.sort {|a,b| a[0]<=>b[0] }
- s = ""
- data.each {|e|
- s = s + "\n\n#{e[0]}\n"
- e[1].sort_by!{|o| o.split(", ")[1] }.sort.each {|r|
- s = s + "\n -> " + r
- }
- }
- open('./desktop/file2.txt', 'w+') {|f| f.write(s) }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement