Advertisement
Azure

Fuck you, webmail. (Parsing a copied search from Hotmail)

Apr 26th, 2012
419
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.67 KB | None | 0 0
  1. # coding: cp850
  2. require 'ap'
  3. f = open('./desktop/file.txt', &:read)
  4. lines = f.split(/\n\(\d+\)/).map{|l|l.strip.gsub("\xE2\x80\x8F","").split("\n").reject(&:"empty?") }
  5. data = {}
  6. lines[1..-1].each {|l|
  7.   next if l[2].match(/^Y's Menettes/)
  8.  month = l[0].scan(/\d+\/\d+$/)[0]
  9.  person = l[2].split(", ")[0].split(" - ")[1].upcase
  10.  data[person] = [] if data[person].nil?
  11.  data[person] << month + " - " + l[2].split(", ")[1]
  12. }
  13.  
  14. data = data.to_a.sort {|a,b| a[0]<=>b[0] }
  15.  
  16. s = ""
  17.  
  18. data.each {|e|
  19.  s = s + "\n\n#{e[0]}\n"
  20.  e[1].sort_by!{|o| o.split(", ")[1] }.sort.each {|r|
  21.    s = s + "\n -> " + r
  22.  }
  23. }
  24.  
  25. open('./desktop/file2.txt', 'w+') {|f| f.write(s) }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement