<commit_before>#!/bin/ruby
# A script to construct `participants.yml` from the people registered in the indico event.

# Author:: <NAME> (mailto:<EMAIL>)
# Copyright:: Copyright (c) 2016 C.S.I.R. Meraka Institute
# License:: Apache 2.0


# Get the CSV file from
# {{ site.data.hackfest.agenda }}/manage/registration/users/?disp=Email&disp=Institution&disp=1-0&disp=1-1&OK=apply&operationType=display&order=down&isBookmark=y&accommShowNoValue=--none--&sortBy=Name&accomm=cern&accomm=geneva-hotel&accomm=own-accommodation&sessionShowNoValue=--none--&statusesShowNoValue=--none--&eventShowNoValue=--none--
#  Be sure  to select following fields :
#   * name
#   * institute
#   *  orcid
#   * github
#   *  username
#   *  confirmed (starts with no)
#   * twitter
#   * homepage
#   * email

# Note : indico doesn't expose getting the participants via their API, so you need to authenticate via username/password
# you can't access this with HTTParty or similar.
# In the meantime, log into indico and dowload the file using a browser

require 'csv'
require 'json'
require 'awesome_print'
require 'yaml'
#  The encoding and headers are important to construct  the JSON later
participants = CSV.read('RegistrantsList-Addis.csv',encoding: "bom|utf-8", headers: :first_row).map { |x| x.to_h}
headers =  CSV.read('RegistrantsList-Addis.csv', encoding: "bom|utf-8", headers: :first_row).headers
ap headers

#  Convert the registrant info to the yml that you need to deploy dev-env
json_headers = ["Name","Institute","orcid","username","confirmed","twitter","homepage","email"]
addis = Array.new
ap addis

participants.each do |p|
  participant = {:name => p["Name"], :institute => p["Institution"], :orcid => p["ORCID ID (see http://orcid.org)"], :github => [{:username => p["GitHub account (see http://github.com)"], :confirmed => false}], :email => p["Email"]}
  addis.push(participant)
end

# print the yaml
ap JSON.parse(addis.to_json).to_yaml
File.open('/tmp/test.yml', 'w') {|f| f.write JSON.parse(addis.to_json).to_yaml } #Store<commit_msg>write to the site-specific file<commit_after>#!/bin/ruby
# A script to construct `participants.yml` from the people registered in the indico event.

# Author:: <NAME> (mailto:<EMAIL>)
# Copyright:: Copyright (c) 2016 C.S.I.R. Meraka Institute
# License:: Apache 2.0


# Get the CSV file from
# {{ site.data.hackfest.agenda }}/manage/registration/users/?disp=Email&disp=Institution&disp=1-0&disp=1-1&OK=apply&operationType=display&order=down&isBookmark=y&accommShowNoValue=--none--&sortBy=Name&accomm=cern&accomm=geneva-hotel&accomm=own-accommodation&sessionShowNoValue=--none--&statusesShowNoValue=--none--&eventShowNoValue=--none--
#  Be sure  to select following fields :
#   * name
#   * institute
#   *  orcid
#   * github
#   *  username
#   *  confirmed (starts with no)
#   * twitter
#   * homepage
#   * email

# Note : indico doesn't expose getting the participants via their API, so you need to authenticate via username/password
# you can't access this with HTTParty or similar.
# In the meantime, log into indico and dowload the file using a browser

require 'csv'
require 'json'
require 'awesome_print'
require 'yaml'
#  The encoding and headers are important to construct  the JSON later
participants = CSV.read('RegistrantsList-Addis.csv',encoding: "bom|utf-8", headers: :first_row).map { |x| x.to_h}
headers =  CSV.read('RegistrantsList-Addis.csv', encoding: "bom|utf-8", headers: :first_row).headers
ap headers

#  Convert the registrant info to the yml that you need to deploy dev-env
json_headers = ["Name","Institute","orcid","username","confirmed","twitter","homepage","email"]
addis = Array.new
ap addis

participants.each do |p|
  participant = {:name => p["Name"], :institute => p["Institution"], :orcid => p["ORCID ID (see http://orcid.org)"], :github => [{:username => p["GitHub account (see http://github.com)"], :confirmed => false}], :email => p["Email"]}
  addis.push(participant)
end

# print the yaml
ap JSON.parse(addis.to_json).to_yaml
File.open('participants-addis.yml', 'w') {|f| f.write JSON.parse(addis.to_json).to_yaml } #Store
{'fraction_non_alphanumeric': 0.1515225334957369, 'fraction_numerical': 0.00584652862362972, 'mean_word_length': 5.082962962962963, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7036739', 'n_tokens_mistral': 1432, 'n_tokens_neox': 1366, 'n_words': 361}