ruby pastebin

Posted by shaklevgmailcom on Mon 6th Apr 06:10 (modification of post by view diff)
download | new post

  1. a= File.read("/users/Houshuang/Downloads/doaj.csv")
  2. c = 0
  3. lang = {}
  4. a.each do |line|
  5.   c=c+1
  6.         t = line.split('","')
  7.   langs = t[2].split(',')
  8.   langs.each do |l|
  9.     l.strip!
  10.     lang[l] = (lang[l] ? lang[l] + 1 : 1)
  11.   end
  12.   break if c == 20000000
  13. end
  14. puts "<table>"
  15. lang.sort {|a,b| b[1]<=>a[1]}.each do |key|
  16.   puts "<tr><td>" + key[0] + "</td><td>" + key[1].to_s + "</td></tr>"
  17. end
  18. puts "</table>In total: #{c}, number of categories: #{lang.size}"

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


I'm Human
Remember me



Captcha required for posting