forked from cncf/gitdm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnew_devs.rb
45 lines (40 loc) · 905 Bytes
/
new_devs.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
require 'csv'
require 'pry'
require './email_code'
def new_devs(files)
known = {}
companies = {}
files.each_with_index do |file, index|
n = 0
CSV.foreach(file, headers: true) do |row|
h = row.to_h
e = email_encode(h['Email'].strip)
c = h['Affliation'].strip
known[e] = 1 if index == 0
unless known.key?(e)
known[e] = 1
n += 1
companies[c] = 0 unless companies.key?(c)
companies[c] += 1
end
end
puts "#{index + 1}) #{file}: N=#{n}" if index > 0
end
arr = []
companies.each do |name, n|
arr << [name, n]
end
arr = arr.sort_by { |item| -item[1] }
ks = %w(company new_devs)
CSV.open("new_devs.csv", "w", headers: ks) do |csv|
csv << ks
arr.each do |row|
csv << row
end
end
end
if ARGV.size < 2
puts "Missing arguments file1 file2 [file3 [...]]"
exit(1)
end
new_devs(ARGV)