-
Notifications
You must be signed in to change notification settings - Fork 4
/
updatenames.rb
executable file
·40 lines (31 loc) · 959 Bytes
/
updatenames.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
#!/usr/bin/env ruby
require 'rubygems'
require 'json'
require 'uri'
require 'rest_client'
require 'yaml'
config = YAML.load(File.read(ENV['HOME'] + '/.getrsvpmeetup.yml'))
$datafile = File.expand_path(config['datafile'])
if File.file?($datafile)
then $memberhash = JSON.load(File.read($datafile))
else $memberhash = {}
end
#cleanednamesfile = ENV['HOME'] + '/Downloads/nylug-out.json'
cleanednamesfile = ENV['HOME'] + '/Downloads/nylug-rsvp-april15-1-clean.json'
if File.file?(cleanednamesfile)
then $nameshash = JSON.load(File.read(cleanednamesfile))
else $nameshash = {}
end
$nameshash.each { |x|
k = x[0].to_s
if $memberhash.has_key?(k)
then
$memberhash[k]['RealName'] = x[1]['RealName']
$memberhash[k]['FirstName'] = x[1]['FirstName']
$memberhash[k]['LastName'] = x[1]['LastName']
end
}
File.open($datafile, 'w') do |file|
file.write JSON.pretty_generate($memberhash)
end
#puts JSON.pretty_generate($memberhash)