VenturaFranklin / ThetaTauAnnualReport

The annual report google scripts for Theta Tau, the professional engineering fraternity
GNU General Public License v3.0
0 stars 0 forks source link

Officer from Member Export in Region Dashboard #169

Open VenturaFranklin opened 6 years ago

VenturaFranklin commented 6 years ago

Currently OER updates Region Dashboard, but if officers updated outside then will not have most up to date officers.

VenturaFranklin commented 6 years ago

Python code to get officers for chapter(s)

'''
Created on Nov 26, 2017

@author: venturf2
'''
import csv
import datetime
# chapter_list = ["Chi", "Delta Gamma", "Epsilon", "Epsilon Delta",
#                 "Kappa Epsilon", "Lambda Delta", "Lambda Epsilon",
#                 "Mu Delta", "NAU Colony", "Omicron Gamma", "Pi Delta",
#                 "Rho Delta", "SCU Colony", "Sigma Delta", "UCSB Colony",
#                 "Upsilon Delta", "Victoria Colony"]
# chapter_list = ["Chi"]
officer_list = ["Regent", "President", "Vice Regent", "Vice President",
                "Scribe", "Corresponding Secretary", "Treasurer"]
officer_list = ["Regent", "President", "Vice Regent", "Vice President",
                "Scribe"]
# chapter_dict = {chapter: {} for chapter in chapter_list}
chapter_dict = {}
file_path = r"E:\ThetaTau Drive\Theta Tau\Nationals\AnnualReport\THETATAU_Members" + \
            r"\20171112_all.CSV"
chapter_col = 'Constituent Specific Attributes Chapter Name Description'
now = datetime.datetime.now()
year = now.year
region_dict = {}
with open(file_path, 'r') as csv_file:
    reader = csv.DictReader(csv_file)
    for row in reader:
        chapter_name = row[chapter_col]
#         if chapter_name in chapter_list:
        region_dict.setdefault(chapter_name, []).append(row)
for chapter_name, chapter_members in region_dict.items():
    for row in chapter_members:
        role = row['Organization Relation Relationship']
        if role != "":
            end_date_str = row['Organization Relation To Date']
            first_name = row['First Name']
            last_name = row['Last Name']
            email = row['Email Address Number']
            role_info = [first_name, last_name, email, end_date_str]
            chapter_dict.setdefault(chapter_name, {})
            chapter_dict[chapter_name].setdefault(role,
                                                  []).append(role_info)
#             print(chapter_name, role, role_info)
for chapter, chapter_roles in chapter_dict.items():
#     print(chapter)
    for role_name, role_member in chapter_roles.items():
        if role_name in officer_list:
#             print("    ", role_name)
            last_end_date = now - datetime.timedelta(days=(1*365))
            final_role_member = role_member[0]
            for role_info in role_member:
                end_date_str = role_info[3]
                if end_date_str != "":
                    end_date = datetime.datetime.strptime(role_info[3], '%m/%d/%Y')
                    if end_date >= last_end_date:
                        final_role_member = role_info
                        last_end_date = end_date
#             print("        ", final_role_member)
            print(final_role_member[2])