scouts_training_reports/appointments_training_reports.py

824 lines
63 KiB
Python

#! python3
#Appointments_Training_Reports.py
#A tool to process Compass Records and produce something human readable using the appointments report
#Licence: GPL-3.0-or-later
#Written by Stuart Griffiths, stuart.griffiths@birminghamscouts.org.uk
#Started 19/05/2022
#Version:0.7
#Released: 30/05/2023
#Status: Working - outputs to 2 seperate CSV files
#Inputs: CSV
#Outputs: multiple CSV and 1 x text file
#Next Steps: upload to Drive?, retrive automatically, send e-mails, working directory selection,
#Issues:
#Background IP: https://automatetheboringstuff.com/, Chapter 16
#Notes - CSV Column Numbers
#Membership_Number = 0
#Surname = 2
#Known_As = 3
#Email = 4
#Telephone = 5
#Member_Role = 8
#Roll_Status = 11
#Roll_Start_Date = 9
#Line_Manager = 13
#Review_Date = 14
#County Section = 18
#District = 19
#District section = 20
#Scout_Group = 21
#CE check = 23
#Advisory committee approval = 24
#commissioner approval = 25
#Committee approval = 26
#References = 27
#Wood badge = 35
#Safety Completed = 36
#Safety Due = 37
#Safeguarding completed = 38
#Safeguarding due = 39
#First Aid Completed = 40
#First Aid Due = 41
#Libraries
import os #Enables file IO
from pathlib import Path #to work out current working directory
import csv #required to handle csv files
import datetime #required to deal with dates for due items
from dateutil.relativedelta import relativedelta #required to calculate 6 months later
#1. Set up Output files
#CSV files
late_mandatory_file = open('late_mandatory_training.csv', 'w', newline='')
late_mandatory = csv.writer(late_mandatory_file)
late_mandatory.writerow(['Membership Number', 'Known_Name', 'Surname', 'E-Mail', 'Telephone', 'Role', 'Line Manager', 'Group', 'District', 'Safety', 'Safeguarding', 'First Aid'])
due_mandatory_file = open('due_mandatory_training.csv', 'w', newline='')
due_mandatory = csv.writer(due_mandatory_file)
due_mandatory.writerow(['Membership Number', 'Known_Name', 'Surname', 'E-Mail', 'Telephone', 'Role', 'Line Manager', 'Group', 'District', 'Safety', 'Safeguarding', 'First Aid'])
#text files
statistics_file = open('_total_training_statistics.txt', 'w')
#Modules
def training_report():
#2. Open the file
file_name = str(Path.cwd()) + '/' + str('County Appointments Report (Beta).csv')
input_file = open(file_name) #assumes file is in working directory
#Create a list using the CSV file
input_data_reader = csv.reader(input_file)
input_data = list(input_data_reader)
#2.1 Set months variable
due_months = 3
#3. Process the data
#Start at row 1 for the OSM output
line_num = int(1) #strips header out
#Ensure we start writing at row 2
row_num_missing = 2
row_num_late = 2
row_num_due = 2
row_num_started = 2
#create lists to process
due_list = []
late_list = []
#create lists for counting purposes
safety_missing_list = []
safeguarding_missing_list = []
firstaid_missing_list = []
safety_due_list = []
safeguarding_due_list = []
firstaid_due_list = []
#create lists for counting purposes county
county_safety_missing_list = []
county_safeguarding_missing_list = []
county_firstaid_missing_list = []
county_safety_due_list = []
county_safeguarding_due_list = []
county_firstaid_due_list = []
#create lists for counting purposes CVS
CVS_safety_missing_list = []
CVS_safeguarding_missing_list = []
CVS_firstaid_missing_list = []
CVS_safety_due_list = []
CVS_safeguarding_due_list = []
CVS_firstaid_due_list = []
#create lists for counting purposes rea
rea_safety_missing_list = []
rea_safeguarding_missing_list = []
rea_firstaid_missing_list = []
rea_safety_due_list = []
rea_safeguarding_due_list = []
rea_firstaid_due_list = []
#create lists for counting purposes SCE
SCE_safety_missing_list = []
SCE_safeguarding_missing_list = []
SCE_firstaid_missing_list = []
SCE_safety_due_list = []
SCE_safeguarding_due_list = []
SCE_firstaid_due_list = []
#create lists for counting purposes SCW
SCW_safety_missing_list = []
SCW_safeguarding_missing_list = []
SCW_firstaid_missing_list = []
SCW_safety_due_list = []
SCW_safeguarding_due_list = []
SCW_firstaid_due_list = []
#create lists for counting purposes spitfire
spitfire_safety_missing_list = []
spitfire_safeguarding_missing_list = []
spitfire_firstaid_missing_list = []
spitfire_safety_due_list = []
spitfire_safeguarding_due_list = []
spitfire_firstaid_due_list = []
#create lists for counting purposes tame
tame_safety_missing_list = []
tame_safeguarding_missing_list = []
tame_firstaid_missing_list = []
tame_safety_due_list = []
tame_safeguarding_due_list = []
tame_firstaid_due_list = []
#to avoid errors
safety_status = False
safeguarding_status = False
firstaid_status = False
safety_due_status = False
safeguarding_due_status = False
firstaid_due_status = False
role_training = False
firstaid_required = False
while line_num < (len(input_data)-1): #while there is an entry to handle, do this
#3.0 Test 0 - Is this the last entry for the person?
#Required to ensure only the primary role is being processed
line_num_next = line_num + 1
current_line_membership = input_data[line_num][0]
try:
next_line_membership = input_data[line_num_next][0]
except:
a= 1
#If membership numbers are equal, we are not at primary role so want to skip to next line
#if they are not equal, we are at primary role and so want to process
if next_line_membership == current_line_membership:
multi_role = True
else:
multi_role = False
if next_line_membership != current_line_membership:
#3.1 acquire dates
today1 = str(datetime.date.today())
today = datetime.datetime.strptime(today1, "%Y-%m-%d") #dodgy work around comparing datetime to date object error
#Establish comparative date - set by variable
Xmonths_later = datetime.datetime.now() + relativedelta(months=+due_months)
#3.2 Does the role require mandatory training?
#Grab the role type
role = input_data[line_num][8]
role_list = ['Group Occasional Helper', 'District Occasional Helper', 'County Occasional Helper', 'County President', 'County Vice President', 'District President', 'District Vice President', 'Group President', 'Group Vice President', 'County TSA Council - Nominated Representative', 'County Sub-Committee Member', 'County Supporter', 'District Supporter', 'Group Supporter', 'County Award Certificate Recipient', 'County Chair', 'District Chair', 'Group Chair', 'Retired Member', 'Group Chairman', 'Scout Network Member']
if role not in role_list:
role_training = True
#Of course some roles do need safety and safeguarding but not first aid....
role_list_first_aid = ['County Treasurer', 'District Treasurer', 'Group Treasurer', 'Section Assistant', 'Group Section Assistant', 'District Section Assistant', 'County Section Assistant', 'County Secretary', 'District Secretary', 'Group Secretary', 'County Treasurer', 'District Treasurer', 'Group Treasurer', 'County Executive Committee Member', 'District Executive Committee Member', 'Group Executive Committee Member', 'Group Executive Committee Member - Elected Member', 'County Appointments Advisory Committee Member', 'District Appointments Advisory Committee Member', 'District Skills Instructor', 'County Skills Instructor', 'Group Skills Instructor', 'County Administrator', 'District Administrator', 'Group Administrator', 'County Badge Secretary', 'District Badge Secretary', 'Group Badge Secretary', 'Scout Active Support Member', 'District Training Administrator', 'County Training Administrator', 'County Chaplain', 'District Chaplain' 'Section Assistant - Squirrel Scouts', 'Section Assistant - Beaver Scouts', 'Section Assistant - Cub Scouts', 'Section Assistant - Scouts', 'District Section Assistant - Explorer Scouts', 'County Scout Active Support Co-ordinator', 'County Scout Active Support Member', 'District Scout Active Support Member', 'Group Scout Active Support Member', 'County Training Adviser', 'County Scout Active Support Manager', 'District Scout Active Support Manager', 'District Training Adviser', 'District Training Adviser - Managers and Supporters', 'Section Assistant - Squirrel Scouts', 'Group Executive Committee Member - Ex-Officio Member', 'Scout Active Support Co-ordinator', 'Group Section Assistant - Beaver Scouts', 'Group Section Assistant - Cub Scouts', 'Group Section Assistant - Scouts', 'Group Executive Committee Member - Ex-Officio Member', 'Section Assistant - Cub Scouts, Beaver Scouts', 'Section Assistant - Group', 'Group Section Assistant - Cub Scouts', 'Group Section Assistant - Scouts', 'Group Section Assistant - Beaver Scouts', 'Group Executive Committee Member - Nominated Member', 'District Chaplain', 'District Appointments Chair', 'District Executive Committee Member - Ex-Officio Member', 'Group Supporter - Quartermaster', 'District Scouter', 'Group Deputy Chair', 'Group Chaplain', 'District Appointments Advisery Committee Member', 'District Executive Committee Member - Nominated Member', 'District Administrator', 'Group Section Assistant - Group' ]
if role not in role_list_first_aid:
firstaid_required = True
#3.3 late to complete testing
#Is the role new and so we don't need to add to missing list yet?
role_start = datetime.datetime.strptime(input_data[line_num][9], "%d/%m/%Y")
role_start_period = role_start + relativedelta(months=+5)
#need to flag if in role start period
if today < role_start_period and multi_role == False:
newbie = True
else:
newbie = False
#3.3.1 safety
#Read the column
safety = input_data[line_num][36]
#print(safety)
#print(input_data[line_num][37])
#Check is it late?
#If date is blank, add to list using membership no, known_name, surname, email, telephone, member_role, manager, group, district, safety due, safeguarding due, first aid due
if safety == "" and role_training == True and newbie == False:
safety_status = True #marker that safety is late
member_number = input_data[line_num][0]
#check whether membership number is in the index and add it if not
try:
x = safety_missing_list.index(member_number)
#if it is, nothing happens
except:
#this executes if the membership number is not in the list
safety_missing_list.append(member_number)
#Get county and district stats
district_name = input_data[line_num][19]
if district_name == '':
county_safety_missing_list.append(member_number)
if district_name == 'Cole Valley South':
CVS_safety_missing_list.append(member_number)
if district_name == 'Rea Valley':
rea_safety_missing_list.append(member_number)
if district_name == 'Birmingham Spitfire District Scout Association':
spitfire_safety_missing_list.append(member_number)
if district_name == 'Sutton Coldfield East':
SCE_safety_missing_list.append(member_number)
if district_name == 'Sutton Coldfield West':
SCW_safety_missing_list.append(member_number)
if district_name == 'Tame Valley Birmingham':
tame_safety_missing_list.append(member_number)
if input_data[line_num][37] != "" and role_training == True and newbie == False:
#Convert string to date object, has to be done here for the blanks!
safety = datetime.datetime.strptime(input_data[line_num][37], "%d/%m/%Y")
#Check is it late?
#If date is less than today when program is ran, add to list using membership no, known_name, surname, email, telephone, member_role, manager, group, district, safety due, safeguarding due, first aid due
if safety < today:
safety_status = True #marker that safety is late
member_number = input_data[line_num][0]
#check whether membership number is in the index and add it if not
try:
x = safety_missing_list.index(member_number)
#if it is, nothing happens
except:
#this executes if the membership number is not in the list
safety_missing_list.append(member_number)
#Get county and district stats
district_name = input_data[line_num][19]
if district_name == '':
county_safety_missing_list.append(member_number)
if district_name == 'Cole Valley South':
CVS_safety_missing_list.append(member_number)
if district_name == 'Rea Valley':
rea_safety_missing_list.append(member_number)
if district_name == 'Birmingham Spitfire District Scout Association':
spitfire_safety_missing_list.append(member_number)
if district_name == 'Sutton Coldfield East':
SCE_safety_missing_list.append(member_number)
if district_name == 'Sutton Coldfield West':
SCW_safety_missing_list.append(member_number)
if district_name == 'Tame Valley Birmingham':
tame_safety_missing_list.append(member_number)
#3.3.2 Safeguarding
#Read the column
safeguarding = input_data[line_num][38]
#Check is it late?
#If date is less than today when program is ran, add to list using membership no, known_name, surname, email, telephone, member_role, manager, group, district, safety due, safeguarding due, first aid due
if safeguarding == "" and role_training == True and newbie == False:
safeguarding_status = True
member_number = input_data[line_num][0]
#check whether membership number is in the index and add it if not
try:
x = safeguarding_missing_list.index(member_number)
#if it is, nothing happens
except:
#this executes if the membership number is not in the list
safeguarding_missing_list.append(member_number)
#Get county and district stats
district_name = input_data[line_num][19]
if district_name == '':
county_safeguarding_missing_list.append(member_number)
if district_name == 'Cole Valley South':
CVS_safeguarding_missing_list.append(member_number)
if district_name == 'Rea Valley':
rea_safeguarding_missing_list.append(member_number)
if district_name == 'Birmingham Spitfire District Scout Association':
spitfire_safeguarding_missing_list.append(member_number)
if district_name == 'Sutton Coldfield East':
SCE_safeguarding_missing_list.append(member_number)
if district_name == 'Sutton Coldfield West':
SCW_safeguarding_missing_list.append(member_number)
if district_name == 'Tame Valley Birmingham':
tame_safeguarding_missing_list.append(member_number)
if input_data[line_num][39] != "" and role_training == True and newbie == False:
#Convert string to date object, has to be done here for the blanks!
safeguarding = datetime.datetime.strptime(input_data[line_num][39], "%d/%m/%Y")
#Check is it late?
#If date is less than today when program is ran, add to list using membership no, known_name, surname, email, telephone, member_role, manager, group, district, safety due, safeguarding due, first aid due
if safeguarding < today:
safeguarding_status = True
member_number = input_data[line_num][0]
#check whether membership number is in the index and add it if not
try:
x = safeguarding_missing_list.index(member_number)
#if it is, nothing happens
except:
#this executes if the membership number is not in the list
safeguarding_missing_list.append(member_number)
#Get county and district stats
district_name = input_data[line_num][19]
if district_name == '':
county_safeguarding_missing_list.append(member_number)
if district_name == 'Cole Valley South':
CVS_safeguarding_missing_list.append(member_number)
if district_name == 'Rea Valley':
rea_safeguarding_missing_list.append(member_number)
if district_name == 'Birmingham Spitfire District Scout Association':
spitfire_safeguarding_missing_list.append(member_number)
if district_name == 'Sutton Coldfield East':
SCE_safeguarding_missing_list.append(member_number)
if district_name == 'Sutton Coldfield West':
SCW_safeguarding_missing_list.append(member_number)
if district_name == 'Tame Valley Birmingham':
tame_safeguarding_missing_list.append(member_number)
#3.3.3 First Aid
#Read the column
firstaid = input_data[line_num][40]
#Check if in first 3 years of role
three_years_later = role_start + relativedelta(months=+36)
#compare to today
if today < three_years_later:
first_3years = True
else:
first_3years = False
#Check is it late?
#If date is blank, not in first 3 years and first aid is required, add to list using membership no, known_name, surname, email, telephone, member_role, manager, group, district, safety due, safeguarding due, first aid due
if firstaid == "" and role_training == True and firstaid_required == True and newbie == False and first_3years == False:
firstaid_status = True
member_number = input_data[line_num][0]
#check whether membership number is in the index and add it if not
try:
x = firstaid_missing_list.index(member_number)
#if it is, nothing happens
except:
#this executes if the membership number is not in the list
firstaid_missing_list.append(member_number)
#Get county and district stats
district_name = input_data[line_num][19]
if district_name == '':
county_firstaid_missing_list.append(member_number)
if district_name == 'Cole Valley South':
CVS_firstaid_missing_list.append(member_number)
if district_name == 'Rea Valley':
rea_firstaid_missing_list.append(member_number)
if district_name == 'Birmingham Spitfire District Scout Association':
spitfire_firstaid_missing_list.append(member_number)
if district_name == 'Sutton Coldfield East':
SCE_firstaid_missing_list.append(member_number)
if district_name == 'Sutton Coldfield West':
SCW_firstaid_missing_list.append(member_number)
if district_name == 'Tame Valley Birmingham':
tame_firstaid_missing_list.append(member_number)
if input_data[line_num][41] != "" and role_training == True and firstaid_required == True and newbie == False:
#Convert string to date object, has to be done here for the blanks!
firstaid = datetime.datetime.strptime(input_data[line_num][41], "%d/%m/%Y")
#Check is it late?
#If date is less than today when program is ran, add to list using membership no, known_name, surname, email, telephone, member_role, manager, group, district, safety due, safeguarding due, first aid due
if firstaid < today:
firstaid_status = True
member_number = input_data[line_num][0]
#check whether membership number is in the index and add it if not
try:
x = firstaid_missing_list.index(member_number)
#if it is, nothing happens
except:
#this executes if the membership number is not in the list
firstaid_missing_list.append(member_number)
#Get county and district stats
district_name = input_data[line_num][19]
if district_name == '':
county_firstaid_missing_list.append(member_number)
if district_name == 'Cole Valley South':
CVS_firstaid_missing_list.append(member_number)
if district_name == 'Rea Valley':
rea_firstaid_missing_list.append(member_number)
if district_name == 'Birmingham Spitfire District Scout Association':
spitfire_firstaid_missing_list.append(member_number)
if district_name == 'Sutton Coldfield East':
SCE_firstaid_missing_list.append(member_number)
if district_name == 'Sutton Coldfield West':
SCW_firstaid_missing_list.append(member_number)
if district_name == 'Tame Valley Birmingham':
tame_firstaid_missing_list.append(member_number)
#3.4 Due training
#3.4.1 Safety
if input_data[line_num][37]:
#Convert string to date object, has to be done here for the blanks!
safety = datetime.datetime.strptime(input_data[line_num][37], "%d/%m/%Y")
#If date is less than 6 momths from when program is ran, add to list using known_name, surname, email, member_role, group, district, training module
if safety < Xmonths_later and safety >= today:
safety_due_status = True
member_number = input_data[line_num][0]
#check whether membership number is in the index and add it if not
try:
x = safety_due_list.index(member_number)
#if it is, nothing happens
except:
#this executes if the membership number is not in the list
safety_due_list.append(member_number)
#Get county and district stats
district_name = input_data[line_num][19]
if district_name == '':
county_safety_due_list.append(member_number)
if district_name == 'Cole Valley South':
CVS_safety_due_list.append(member_number)
if district_name == 'Rea Valley':
rea_safety_due_list.append(member_number)
if district_name == 'Birmingham Spitfire District Scout Association':
spitfire_safety_due_list.append(member_number)
if district_name == 'Sutton Coldfield East':
SCE_safety_due_list.append(member_number)
if district_name == 'Sutton Coldfield West':
SCW_safety_due_list.append(member_number)
if district_name == 'Tame Valley Birmingham':
tame_safety_due_list.append(member_number)
#3.4.2 Safeguarding
if input_data[line_num][39] != "":
#Convert string to date object, has to be done here for the blanks!
safeguarding = datetime.datetime.strptime(input_data[line_num][39], "%d/%m/%Y")
#If date is less than 6 months from when program is ran, add to list using known_name, surname, email, member_role, group, district, training module
if safeguarding < Xmonths_later and safeguarding >= today:
safeguarding_due_status = True
member_number = input_data[line_num][0]
#check whether membership number is in the index and add it if not
try:
x = safeguarding_due_list.index(member_number)
#if it is, nothing happens
except:
#this executes if the membership number is not in the list
safeguarding_due_list.append(member_number)
#Get county and district stats
district_name = input_data[line_num][19]
if district_name == '':
county_safeguarding_due_list.append(member_number)
if district_name == 'Cole Valley South':
CVS_safeguarding_due_list.append(member_number)
if district_name == 'Rea Valley':
rea_safeguarding_due_list.append(member_number)
if district_name == 'Birmingham Spitfire District Scout Association':
spitfire_safeguarding_due_list.append(member_number)
if district_name == 'Sutton Coldfield East':
SCE_safeguarding_due_list.append(member_number)
if district_name == 'Sutton Coldfield West':
SCW_safeguarding_due_list.append(member_number)
if district_name == 'Tame Valley Birmingham':
tame_safeguarding_due_list.append(member_number)
#3.4.3 First Aid
if input_data[line_num][41] != "":
#Convert string to date object, has to be done here for the blanks!
firstaid = datetime.datetime.strptime(input_data[line_num][41], "%d/%m/%Y")
#Check if in first 3 years of role
three_years_later = role_start + relativedelta(months=+36)
#If date is less than 6 months from when program is ran, add to list using known_name, surname, email, member_role, group, district, training module
if firstaid < Xmonths_later and firstaid >= today and today >= three_years_later:
firstaid_due_status = True
member_number = input_data[line_num][0]
#check whether membership number is in the index and add it if not
try:
x = firstaid_due_list.index(member_number)
#if it is, nothing happens
except:
#this executes if the membership number is not in the list
firstaid_due_list.append(member_number)
#Get county and district stats
district_name = input_data[line_num][19]
if district_name == '':
county_firstaid_due_list.append(member_number)
if district_name == 'Cole Valley South':
CVS_firstaid_due_list.append(member_number)
if district_name == 'Rea Valley':
rea_firstaid_due_list.append(member_number)
if district_name == 'Birmingham Spitfire District Scout Association':
spitfire_firstaid_due_list.append(member_number)
if district_name == 'Sutton Coldfield East':
SCE_firstaid_due_list.append(member_number)
if district_name == 'Sutton Coldfield West':
SCW_firstaid_due_list.append(member_number)
if district_name == 'Tame Valley Birmingham':
tame_firstaid_due_list.append(member_number)
#4: Construct the file outputs
#Late or missing training
#single one only
if safety_status == True and safeguarding_status != True and firstaid_status != True and role_training == True and firstaid_required == True:
#write only with the safety status
if input_data[line_num][36] == '':
late_mandatory.writerow([input_data[line_num][0], input_data[line_num][3], input_data[line_num][2], input_data[line_num][4], input_data[line_num][5], input_data[line_num][8], input_data[line_num][13], input_data[line_num][21], input_data[line_num][19], 'Never Completed', 'Up To Date', 'Up To Date'])
else:
late_mandatory.writerow([input_data[line_num][0], input_data[line_num][3], input_data[line_num][2], input_data[line_num][4], input_data[line_num][5], input_data[line_num][8], input_data[line_num][13], input_data[line_num][21], input_data[line_num][19], input_data[line_num][37], 'Up To Date', 'Up To Date'])
if safety_status == True and safeguarding_status != True and firstaid_status != True and role_training == True and firstaid_required == False:
#write only with the safety status
if input_data[line_num][36] == '':
late_mandatory.writerow([input_data[line_num][0], input_data[line_num][3], input_data[line_num][2], input_data[line_num][4], input_data[line_num][5], input_data[line_num][8], input_data[line_num][13], input_data[line_num][21], input_data[line_num][19], 'Never Completed', 'Up To Date', 'Not Required'])
else:
late_mandatory.writerow([input_data[line_num][0], input_data[line_num][3], input_data[line_num][2], input_data[line_num][4], input_data[line_num][5], input_data[line_num][8], input_data[line_num][13], input_data[line_num][21], input_data[line_num][19], input_data[line_num][37], 'Up To Date', 'Not Required'])
if safety_status != True and safeguarding_status == True and firstaid_status != True and role_training == True and firstaid_required == True:
#write only with the safeguarding status
if input_data[line_num][38] == '':
late_mandatory.writerow([input_data[line_num][0], input_data[line_num][3], input_data[line_num][2], input_data[line_num][4], input_data[line_num][5], input_data[line_num][8], input_data[line_num][13], input_data[line_num][21], input_data[line_num][19], 'Up To Date', 'Never Completed', 'Up To Date'])
else:
late_mandatory.writerow([input_data[line_num][0], input_data[line_num][3], input_data[line_num][2], input_data[line_num][4], input_data[line_num][5], input_data[line_num][8], input_data[line_num][13], input_data[line_num][21], input_data[line_num][19], 'Up To Date', input_data[line_num][39], 'Up To Date'])
if safety_status != True and safeguarding_status == True and firstaid_status != True and role_training == True and firstaid_required == False:
#write only with the safeguarding status
if input_data[line_num][38] == '':
late_mandatory.writerow([input_data[line_num][0], input_data[line_num][3], input_data[line_num][2], input_data[line_num][4], input_data[line_num][5], input_data[line_num][8], input_data[line_num][13], input_data[line_num][21], input_data[line_num][19], 'Up To Date', 'Never Completed', 'Not Required'])
else:
late_mandatory.writerow([input_data[line_num][0], input_data[line_num][3], input_data[line_num][2], input_data[line_num][4], input_data[line_num][5], input_data[line_num][8], input_data[line_num][13], input_data[line_num][21], input_data[line_num][19], 'Up To Date', input_data[line_num][39], 'Not Required'])
if safety_status != True and safeguarding_status != True and firstaid_status == True and role_training == True and firstaid_required == True:
#write only with the first aid status
if input_data[line_num][40] == '':
late_mandatory.writerow([input_data[line_num][0], input_data[line_num][3], input_data[line_num][2], input_data[line_num][4], input_data[line_num][5], input_data[line_num][8], input_data[line_num][13], input_data[line_num][21], input_data[line_num][19], 'Up To Date', 'Up To Date', 'Never Completed'])
else:
late_mandatory.writerow([input_data[line_num][0], input_data[line_num][3], input_data[line_num][2], input_data[line_num][4], input_data[line_num][5], input_data[line_num][8], input_data[line_num][13], input_data[line_num][21], input_data[line_num][19], 'Up To Date', 'Up To Date', input_data[line_num][41]])
# x2 combo only
if safety_status == True and safeguarding_status == True and firstaid_status != True and role_training == True and firstaid_required == True:
#write safety and safeguarding status
if input_data[line_num][36] == '' and input_data[line_num][38] == '':
late_mandatory.writerow([input_data[line_num][0], input_data[line_num][3], input_data[line_num][2], input_data[line_num][4], input_data[line_num][5], input_data[line_num][8], input_data[line_num][13], input_data[line_num][21], input_data[line_num][19], 'Never Completed', 'Never Completed', 'Up To Date'])
else:
late_mandatory.writerow([input_data[line_num][0], input_data[line_num][3], input_data[line_num][2], input_data[line_num][4], input_data[line_num][5], input_data[line_num][8], input_data[line_num][13], input_data[line_num][21], input_data[line_num][19], input_data[line_num][37], input_data[line_num][39], 'Up To Date'])
if safety_status == True and safeguarding_status == True and firstaid_status != True and role_training == True and firstaid_required == False:
#write safety and safeguarding status
if input_data[line_num][36] == '' and input_data[line_num][38] == '':
late_mandatory.writerow([input_data[line_num][0], input_data[line_num][3], input_data[line_num][2], input_data[line_num][4], input_data[line_num][5], input_data[line_num][8], input_data[line_num][13], input_data[line_num][21], input_data[line_num][19], 'Never Completed', 'Never Completed', 'Not Required'])
else:
late_mandatory.writerow([input_data[line_num][0], input_data[line_num][3], input_data[line_num][2], input_data[line_num][4], input_data[line_num][5], input_data[line_num][8], input_data[line_num][13], input_data[line_num][21], input_data[line_num][19], input_data[line_num][37], input_data[line_num][39], 'Not Required'])
if safety_status == True and safeguarding_status != True and firstaid_status == True and role_training == True and firstaid_required == True:
#write safety and first aid status
if input_data[line_num][36] == '' and input_data[line_num][40] == '':
late_mandatory.writerow([input_data[line_num][0], input_data[line_num][3], input_data[line_num][2], input_data[line_num][4], input_data[line_num][5], input_data[line_num][8], input_data[line_num][13], input_data[line_num][21], input_data[line_num][19], 'Never Completed' , 'Up To Date', 'Never Completed'])
else:
late_mandatory.writerow([input_data[line_num][0], input_data[line_num][3], input_data[line_num][2], input_data[line_num][4], input_data[line_num][5], input_data[line_num][8], input_data[line_num][13], input_data[line_num][21], input_data[line_num][19], input_data[line_num][37] , 'Up To Date', input_data[line_num][41]])
if safety_status != True and safeguarding_status == True and firstaid_status == True and role_training == True and firstaid_required == True:
#write safeguarding and first aid status
if input_data[line_num][38] == '' and input_data[line_num][40] == '':
late_mandatory.writerow([input_data[line_num][0], input_data[line_num][3], input_data[line_num][2], input_data[line_num][4], input_data[line_num][5], input_data[line_num][8], input_data[line_num][13], input_data[line_num][21], input_data[line_num][19], 'Up To Date', 'Never Completed', 'Never Completed'])
else:
late_mandatory.writerow([input_data[line_num][0], input_data[line_num][3], input_data[line_num][2], input_data[line_num][4], input_data[line_num][5], input_data[line_num][8], input_data[line_num][13], input_data[line_num][21], input_data[line_num][19], 'Up To Date', input_data[line_num][39], input_data[line_num][41]])
# all 3
if safety_status == True and safeguarding_status == True and firstaid_status == True and role_training == True and firstaid_required == True:
#write safety, safeguarding and first aid status
if input_data[line_num][36] == '' and input_data[line_num][38] == '' and input_data[line_num][40] == '':
late_mandatory.writerow([input_data[line_num][0], input_data[line_num][3], input_data[line_num][2], input_data[line_num][4], input_data[line_num][5], input_data[line_num][8], input_data[line_num][13], input_data[line_num][21], input_data[line_num][19], 'Never Completed', 'Never Completed', 'Never Completed'])
else:
late_mandatory.writerow([input_data[line_num][0], input_data[line_num][3], input_data[line_num][2], input_data[line_num][4], input_data[line_num][5], input_data[line_num][8], input_data[line_num][13], input_data[line_num][21], input_data[line_num][19], input_data[line_num][37], input_data[line_num][39], input_data[line_num][41]])
#Due training
#single one only
if safety_due_status == True and safeguarding_due_status != True and firstaid_due_status != True and role_training == True:
#write only with the safety status
due_mandatory.writerow([input_data[line_num][0], input_data[line_num][3], input_data[line_num][2], input_data[line_num][4], input_data[line_num][5], input_data[line_num][8], input_data[line_num][13], input_data[line_num][21], input_data[line_num][19], input_data[line_num][37], "", ""])
if safety_due_status != True and safeguarding_due_status == True and firstaid_due_status != True and role_training == True:
#write only with the safeguarding status
due_mandatory.writerow([input_data[line_num][0], input_data[line_num][3], input_data[line_num][2], input_data[line_num][4], input_data[line_num][5], input_data[line_num][8], input_data[line_num][13], input_data[line_num][21], input_data[line_num][19], '', input_data[line_num][39], ""])
if safety_due_status != True and safeguarding_due_status != True and firstaid_due_status == True and role_training == True and firstaid_required == True:
#write only with the first aid status
due_mandatory.writerow([input_data[line_num][0], input_data[line_num][3], input_data[line_num][2], input_data[line_num][4], input_data[line_num][5], input_data[line_num][8], input_data[line_num][13], input_data[line_num][21], input_data[line_num][19], '', '', input_data[line_num][41]])
# x2 combo only
if safety_due_status == True and safeguarding_due_status == True and firstaid_due_status != True and role_training == True:
#write safety and safeguarding status
due_mandatory.writerow([input_data[line_num][0], input_data[line_num][3], input_data[line_num][2], input_data[line_num][4], input_data[line_num][5], input_data[line_num][8], input_data[line_num][13], input_data[line_num][21], input_data[line_num][19], input_data[line_num][37], input_data[line_num][39], ""])
if safety_due_status == True and safeguarding_due_status != True and firstaid_due_status == True and role_training == True and firstaid_required == True:
#write safety and first aid status
due_mandatory.writerow([input_data[line_num][0], input_data[line_num][3], input_data[line_num][2], input_data[line_num][4], input_data[line_num][5], input_data[line_num][8], input_data[line_num][13], input_data[line_num][21], input_data[line_num][19], input_data[line_num][37] , '', input_data[line_num][41]])
if safety_due_status != True and safeguarding_due_status == True and firstaid_due_status == True and role_training == True and firstaid_required == True:
#write safeguarding and first aid status
due_mandatory.writerow([input_data[line_num][0], input_data[line_num][3], input_data[line_num][2], input_data[line_num][4], input_data[line_num][5], input_data[line_num][8], input_data[line_num][13], input_data[line_num][21], input_data[line_num][19], '', input_data[line_num][39], input_data[line_num][41]])
# all 3
if safety_due_status == True and safeguarding_due_status == True and firstaid_due_status == True and role_training == True and firstaid_required == True:
#write safety, safeguarding and first aid status
due_mandatory.writerow([input_data[line_num][0], input_data[line_num][3], input_data[line_num][2], input_data[line_num][4], input_data[line_num][5], input_data[line_num][8], input_data[line_num][13], input_data[line_num][21], input_data[line_num][19], input_data[line_num][37], input_data[line_num][39], input_data[line_num][41]])
# Clear everything up to avoid printing same old stuff again and again
safety_status = False
safeguarding_status = False
firstaid_status = False
safety_due_status = False
safeguarding_due_status = False
firstaid_due_status = False
role_training = False
firstaid_required = False
newbie = False
line_num = line_num + 1 #continues the loop
#print(input_data[line_num][0])
#4: Statistics Generation Time
statistics_file.write('Statistics File for Training Reports\n')
statistics_file.write('====================================\n')
statistics_file.write('\n')
statistics_file.write('Leaders who are late with Safety module: ' + str(len(safety_missing_list))+'\n')
statistics_file.write('Leaders who need to complete the Safety module within ' + str(due_months) + ' months: ' + str(len(safety_due_list))+'\n')
statistics_file.write('Leaders who are late with Safeguarding module: ' + str(len(safeguarding_missing_list))+'\n')
statistics_file.write('Leaders who need to complete the Safeguarding module within ' + str(due_months) + ' months: ' + str(len(safeguarding_due_list))+'\n')
statistics_file.write('Leaders who are late with First Aid module: ' + str(len(firstaid_missing_list))+'\n')
statistics_file.write('Leaders who need to complete the First Aid module within ' + str(due_months) + ' months: ' + str(len(firstaid_due_list))+'\n')
statistics_file.write('\n')
statistics_file.write('County Roles\n')
statistics_file.write('============\n')
statistics_file.write('Leaders who are late with Safety module: ' + str(len(county_safety_missing_list))+'\n')
statistics_file.write('Leaders who need to complete the Safety module within ' + str(due_months) + ' months: ' + str(len(county_safety_due_list))+'\n')
statistics_file.write('Leaders who are late with Safeguarding module: ' + str(len(county_safeguarding_missing_list))+'\n')
statistics_file.write('Leaders who need to complete the Safeguarding module within ' + str(due_months) + ' months: ' + str(len(county_safeguarding_due_list))+'\n')
statistics_file.write('Leaders who are late with First Aid module: ' + str(len(county_firstaid_missing_list))+'\n')
statistics_file.write('Leaders who need to complete the First Aid module within ' + str(due_months) + ' months: ' + str(len(county_firstaid_due_list))+'\n')
statistics_file.write('\n')
statistics_file.write('Cole Valley South Roles\n')
statistics_file.write('=======================\n')
statistics_file.write('Leaders who are late with Safety module: ' + str(len(CVS_safety_missing_list))+'\n')
statistics_file.write('Leaders who need to complete the Safety module within ' + str(due_months) + ' months: ' + str(len(CVS_safety_due_list))+'\n')
statistics_file.write('Leaders who are late with Safeguarding module: ' + str(len(CVS_safeguarding_missing_list))+'\n')
statistics_file.write('Leaders who need to complete the Safeguarding module within ' + str(due_months) + ' months: ' + str(len(CVS_safeguarding_due_list))+'\n')
statistics_file.write('Leaders who are late with First Aid module: ' + str(len(CVS_firstaid_missing_list))+'\n')
statistics_file.write('Leaders who need to complete the First Aid module within ' + str(due_months) + ' months: ' + str(len(CVS_firstaid_due_list))+'\n')
statistics_file.write('\n')
statistics_file.write('Rea Valley Roles\n')
statistics_file.write('================\n')
statistics_file.write('Leaders who are late with Safety module: ' + str(len(rea_safety_missing_list))+'\n')
statistics_file.write('Leaders who need to complete the Safety module within ' + str(due_months) + ' months: ' + str(len(rea_safety_due_list))+'\n')
statistics_file.write('Leaders who are late with Safeguarding module: ' + str(len(rea_safeguarding_missing_list))+'\n')
statistics_file.write('Leaders who need to complete the Safeguarding module within ' + str(due_months) + ' months: ' + str(len(rea_safeguarding_due_list))+'\n')
statistics_file.write('Leaders who are late with First Aid module: ' + str(len(rea_firstaid_missing_list))+'\n')
statistics_file.write('Leaders who need to complete the First Aid module within ' + str(due_months) + ' months: ' + str(len(rea_firstaid_due_list))+'\n')
statistics_file.write('\n')
statistics_file.write('Spitfire Roles\n')
statistics_file.write('==============\n')
statistics_file.write('Leaders who are late with Safety module: ' + str(len(spitfire_safety_missing_list))+'\n')
statistics_file.write('Leaders who need to complete the Safety module within ' + str(due_months) + ' months: ' + str(len(spitfire_safety_due_list))+'\n')
statistics_file.write('Leaders who are late with Safeguarding module: ' + str(len(spitfire_safeguarding_missing_list))+'\n')
statistics_file.write('Lprinteaders who need to complete the Safeguarding module within ' + str(due_months) + ' months: ' + str(len(spitfire_safeguarding_due_list))+'\n')
statistics_file.write('Leaders who are late with First Aid module: ' + str(len(spitfire_firstaid_missing_list))+'\n')
statistics_file.write('Leaders who need to complete the First Aid module within ' + str(due_months) + ' months: ' + str(len(spitfire_firstaid_due_list))+'\n')
statistics_file.write('\n')
statistics_file.write('Sutton Coldfield East Roles\n')
statistics_file.write('===========================\n')
statistics_file.write('Leaders who are late with Safety module: ' + str(len(SCE_safety_missing_list))+'\n')
statistics_file.write('Leaders who need to complete the Safety module within ' + str(due_months) + ' months: ' + str(len(SCE_safety_due_list))+'\n')
statistics_file.write('Leaders who are late with Safeguarding module: ' + str(len(SCE_safeguarding_missing_list))+'\n')
statistics_file.write('Leaders who need to complete the Safeguarding module within ' + str(due_months) + ' months: ' + str(len(SCE_safeguarding_due_list))+'\n')
statistics_file.write('Leaders who are late with First Aid module: ' + str(len(SCE_firstaid_missing_list))+'\n')
statistics_file.write('Leaders who need to complete the First Aid module within ' + str(due_months) + ' months: ' + str(len(SCE_firstaid_due_list))+'\n')
statistics_file.write('\n')
statistics_file.write('Sutton Coldfield West Roles\n')
statistics_file.write('===========================\n')
statistics_file.write('Leaders who are late with Safety module: ' + str(len(SCW_safety_missing_list))+'\n')
statistics_file.write('Leaders who need to complete the Safety module within ' + str(due_months) + ' months: ' + str(len(SCW_safety_due_list))+'\n')
statistics_file.write('Leaders who are late with Safeguarding module: ' + str(len(SCW_safeguarding_missing_list))+'\n')
statistics_file.write('Leaders who need to complete the Safeguarding module within ' + str(due_months) + ' months: ' + str(len(SCW_safeguarding_due_list))+'\n')
statistics_file.write('Leaders who are late with First Aid module: ' + str(len(SCW_firstaid_missing_list))+'\n')
statistics_file.write('Leaders who need to complete the First Aid module within ' + str(due_months) + ' months: ' + str(len(SCW_firstaid_due_list))+'\n')
statistics_file.write('\n')
statistics_file.write('Tame Valley Roles\n')
statistics_file.write('===========================\n')
statistics_file.write('Leaders who are late with Safety module: ' + str(len(tame_safety_missing_list))+'\n')
statistics_file.write('Leaders who need to complete the Safety module within ' + str(due_months) + ' months: ' + str(len(tame_safety_due_list))+'\n')
statistics_file.write('Leaders who are late with Safeguarding module: ' + str(len(tame_safeguarding_missing_list))+'\n')
statistics_file.write('Leaders who need to complete the Safeguarding module within ' + str(due_months) + ' months: ' + str(len(tame_safeguarding_due_list))+'\n')
statistics_file.write('Leaders who are late with First Aid module: ' + str(len(tame_firstaid_missing_list))+'\n')
statistics_file.write('Leaders who need to complete the First Aid module within ' + str(due_months) + ' months: ' + str(len(tame_firstaid_due_list))+'\n')
statistics_file.write('\n')
#5: Close files to show they are done
late_mandatory_file.close()
due_mandatory_file.close()
print("Finished the County part!")
def districts_reports():
#Runs after missing and soon due training has been listed. Produces district reports
#County
county_late_mandatory_file = open('county_late_mandatory_training.csv', 'w', newline='')
county_late_mandatory = csv.writer(county_late_mandatory_file)
county_late_mandatory.writerow(['Membership Number', 'Known_Name', 'Surname', 'E-Mail', 'Telephone', 'Role', 'Line Manager', 'Group', 'District', 'Safety', 'Safeguarding', 'First Aid'])
county_due_mandatory_file = open('county_due_mandatory_training.csv', 'w', newline='')
county_due_mandatory = csv.writer(county_due_mandatory_file)
county_due_mandatory.writerow(['Membership Number', 'Known_Name', 'Surname', 'E-Mail', 'Telephone', 'Role', 'Line Manager', 'Group', 'District', 'Safety', 'Safeguarding', 'First Aid'])
#Districts
CVS_late_mandatory_file = open('CVS_late_mandatory_training.csv', 'w', newline='')
CVS_late_mandatory = csv.writer(CVS_late_mandatory_file)
CVS_late_mandatory.writerow(['Membership Number', 'Known_Name', 'Surname', 'E-Mail', 'Telephone', 'Role', 'Line Manager', 'Group', 'District', 'Safety', 'Safeguarding', 'First Aid'])
CVS_due_mandatory_file = open('CVS_due_mandatory_training.csv', 'w', newline='')
CVS_due_mandatory = csv.writer(CVS_due_mandatory_file)
CVS_due_mandatory.writerow(['Membership Number', 'Known_Name', 'Surname', 'E-Mail', 'Telephone', 'Role', 'Line Manager', 'Group', 'District', 'Safety', 'Safeguarding', 'First Aid'])
spitfire_late_mandatory_file = open('spitfire_late_mandatory_training.csv', 'w', newline='')
spitfire_late_mandatory = csv.writer(spitfire_late_mandatory_file)
spitfire_late_mandatory.writerow(['Membership Number', 'Known_Name', 'Surname', 'E-Mail', 'Telephone', 'Role', 'Line Manager', 'Group', 'District', 'Safety', 'Safeguarding', 'First Aid'])
spitfire_due_mandatory_file = open('spitfire_due_mandatory_training.csv', 'w', newline='')
spitfire_due_mandatory = csv.writer(spitfire_due_mandatory_file)
spitfire_due_mandatory.writerow(['Membership Number', 'Known_Name', 'Surname', 'E-Mail', 'Telephone', 'Role', 'Line Manager', 'Group', 'District', 'Safety', 'Safeguarding', 'First Aid'])
SCE_late_mandatory_file = open('SCE_late_mandatory_training.csv', 'w', newline='')
SCE_late_mandatory = csv.writer(SCE_late_mandatory_file)
SCE_late_mandatory.writerow(['Membership Number', 'Known_Name', 'Surname', 'E-Mail', 'Telephone', 'Role', 'Line Manager', 'Group', 'District', 'Safety', 'Safeguarding', 'First Aid'])
SCE_due_mandatory_file = open('SCE_due_mandatory_training.csv', 'w', newline='')
SCE_due_mandatory = csv.writer(SCE_due_mandatory_file)
SCE_due_mandatory.writerow(['Membership Number', 'Known_Name', 'Surname', 'E-Mail', 'Telephone', 'Role', 'Line Manager', 'Group', 'District', 'Safety', 'Safeguarding', 'First Aid'])
SCW_late_mandatory_file = open('SCW_late_mandatory_training.csv', 'w', newline='')
SCW_late_mandatory = csv.writer(SCW_late_mandatory_file)
SCW_late_mandatory.writerow(['Membership Number', 'Known_Name', 'Surname', 'E-Mail', 'Telephone', 'Role', 'Line Manager', 'Group', 'District', 'Safety', 'Safeguarding', 'First Aid'])
SCW_due_mandatory_file = open('SCW_due_mandatory_training.csv', 'w', newline='')
SCW_due_mandatory = csv.writer(SCW_due_mandatory_file)
SCW_due_mandatory.writerow(['Membership Number', 'Known_Name', 'Surname', 'E-Mail', 'Telephone', 'Role', 'Line Manager', 'Group', 'District', 'Safety', 'Safeguarding', 'First Aid'])
rea_late_mandatory_file = open('rea_late_mandatory_training.csv', 'w', newline='')
rea_late_mandatory = csv.writer(rea_late_mandatory_file)
rea_late_mandatory.writerow(['Membership Number', 'Known_Name', 'Surname', 'E-Mail', 'Telephone', 'Role', 'Line Manager', 'Group', 'District', 'Safety', 'Safeguarding', 'First Aid'])
rea_due_mandatory_file = open('rea_due_mandatory_training.csv', 'w', newline='')
rea_due_mandatory = csv.writer(rea_due_mandatory_file)
rea_due_mandatory.writerow(['Membership Number', 'Known_Name', 'Surname', 'E-Mail', 'Telephone', 'Role', 'Line Manager', 'Group', 'District', 'Safety', 'Safeguarding', 'First Aid'])
tame_late_mandatory_file = open('tame_late_mandatory_training.csv', 'w', newline='')
tame_late_mandatory = csv.writer(tame_late_mandatory_file)
tame_late_mandatory.writerow(['Membership Number', 'Known_Name', 'Surname', 'E-Mail', 'Telephone', 'Role', 'Line Manager', 'Group', 'District', 'Safety', 'Safeguarding', 'First Aid'])
tame_due_mandatory_file = open('tame_due_mandatory_training.csv', 'w', newline='')
tame_due_mandatory = csv.writer(tame_due_mandatory_file)
tame_due_mandatory.writerow(['Membership Number', 'Known_Name', 'Surname', 'E-Mail', 'Telephone', 'Role', 'Line Manager', 'Group', 'District', 'Safety', 'Safeguarding', 'First Aid'])
#6. late reports
#Open the file
file_name = str(Path.cwd()) + '/' + str('late_mandatory_training.csv')
input_file = open(file_name) #assumes file is in working directory
#Create a list using the CSV file
input_data_reader = csv.reader(input_file)
input_data = list(input_data_reader)
#6.2 Process the data
#start at row 2 to strip header out
line_num = int(1)
while line_num < (len(input_data)-1): #While there is an entry to handle, do something
#read District info (8)
district = input_data[line_num][8]
if district == '':
#If no district, must be county
county_late_mandatory.writerow([input_data[line_num][0], input_data[line_num][1], input_data[line_num][2], input_data[line_num][3], input_data[line_num][4], input_data[line_num][5], input_data[line_num][6], input_data[line_num][7], input_data[line_num][8], input_data[line_num][9], input_data[line_num][10], input_data[line_num][11]])
if district == 'Cole Valley South':
CVS_late_mandatory.writerow([input_data[line_num][0], input_data[line_num][1], input_data[line_num][2], input_data[line_num][3], input_data[line_num][4], input_data[line_num][5], input_data[line_num][6], input_data[line_num][7], input_data[line_num][8], input_data[line_num][9], input_data[line_num][10], input_data[line_num][11]])
if district == 'Birmingham Spitfire District Scout Association':
spitfire_late_mandatory.writerow([input_data[line_num][0], input_data[line_num][1], input_data[line_num][2], input_data[line_num][3], input_data[line_num][4], input_data[line_num][5], input_data[line_num][6], input_data[line_num][7], input_data[line_num][8], input_data[line_num][9], input_data[line_num][10], input_data[line_num][11]])
if district == 'Sutton Coldfield East':
SCE_late_mandatory.writerow([input_data[line_num][0], input_data[line_num][1], input_data[line_num][2], input_data[line_num][3], input_data[line_num][4], input_data[line_num][5], input_data[line_num][6], input_data[line_num][7], input_data[line_num][8], input_data[line_num][9], input_data[line_num][10], input_data[line_num][11]])
if district == 'Sutton Coldfield West':
SCW_late_mandatory.writerow([input_data[line_num][0], input_data[line_num][1], input_data[line_num][2], input_data[line_num][3], input_data[line_num][4], input_data[line_num][5], input_data[line_num][6], input_data[line_num][7], input_data[line_num][8], input_data[line_num][9], input_data[line_num][10], input_data[line_num][11]])
if district == 'Rea Valley':
rea_late_mandatory.writerow([input_data[line_num][0], input_data[line_num][1], input_data[line_num][2], input_data[line_num][3], input_data[line_num][4], input_data[line_num][5], input_data[line_num][6], input_data[line_num][7], input_data[line_num][8], input_data[line_num][9], input_data[line_num][10], input_data[line_num][11]])
if district == 'Tame Valley Birmingham':
tame_late_mandatory.writerow([input_data[line_num][0], input_data[line_num][1], input_data[line_num][2], input_data[line_num][3], input_data[line_num][4], input_data[line_num][5], input_data[line_num][6], input_data[line_num][7], input_data[line_num][8], input_data[line_num][9], input_data[line_num][10], input_data[line_num][11]])
line_num = line_num + 1
#7. late reports
#Open the file
file_name = str(Path.cwd()) + '/' + str('due_mandatory_training.csv')
input_file = open(file_name) #assumes file is in working directory
#Create a list using the CSV file
input_data_reader = csv.reader(input_file)
input_data = list(input_data_reader)
#7.2 Process the data
#start at row 2 to strip header out
line_num = int(1)
while line_num < (len(input_data)-1): #While there is an entry to handle, do something
#read District info (8)
district = input_data[line_num][8]
if district == '':
#If no district, must be county
county_due_mandatory.writerow([input_data[line_num][0], input_data[line_num][1], input_data[line_num][2], input_data[line_num][3], input_data[line_num][4], input_data[line_num][5], input_data[line_num][6], input_data[line_num][7], input_data[line_num][8], input_data[line_num][9], input_data[line_num][10], input_data[line_num][11]])
if district == 'Cole Valley South':
CVS_due_mandatory.writerow([input_data[line_num][0], input_data[line_num][1], input_data[line_num][2], input_data[line_num][3], input_data[line_num][4], input_data[line_num][5], input_data[line_num][6], input_data[line_num][7], input_data[line_num][8], input_data[line_num][9], input_data[line_num][10], input_data[line_num][11]])
if district == 'Birmingham Spitfire District Scout Association':
spitfire_due_mandatory.writerow([input_data[line_num][0], input_data[line_num][1], input_data[line_num][2], input_data[line_num][3], input_data[line_num][4], input_data[line_num][5], input_data[line_num][6], input_data[line_num][7], input_data[line_num][8], input_data[line_num][9], input_data[line_num][10], input_data[line_num][11]])
if district == 'Sutton Coldfield East':
SCE_due_mandatory.writerow([input_data[line_num][0], input_data[line_num][1], input_data[line_num][2], input_data[line_num][3], input_data[line_num][4], input_data[line_num][5], input_data[line_num][6], input_data[line_num][7], input_data[line_num][8], input_data[line_num][9], input_data[line_num][10], input_data[line_num][11]])
if district == 'Sutton Coldfield West':
SCW_due_mandatory.writerow([input_data[line_num][0], input_data[line_num][1], input_data[line_num][2], input_data[line_num][3], input_data[line_num][4], input_data[line_num][5], input_data[line_num][6], input_data[line_num][7], input_data[line_num][8], input_data[line_num][9], input_data[line_num][10], input_data[line_num][11]])
if district == 'Rea Valley':
rea_due_mandatory.writerow([input_data[line_num][0], input_data[line_num][1], input_data[line_num][2], input_data[line_num][3], input_data[line_num][4], input_data[line_num][5], input_data[line_num][6], input_data[line_num][7], input_data[line_num][8], input_data[line_num][9], input_data[line_num][10], input_data[line_num][11]])
if district == 'Tame Valley Birmingham':
tame_due_mandatory.writerow([input_data[line_num][0], input_data[line_num][1], input_data[line_num][2], input_data[line_num][3], input_data[line_num][4], input_data[line_num][5], input_data[line_num][6], input_data[line_num][7], input_data[line_num][8], input_data[line_num][9], input_data[line_num][10], input_data[line_num][11]])
line_num = line_num + 1 #continues the loop
#8: Close the files
county_late_mandatory_file.close()
county_due_mandatory_file.close()
CVS_late_mandatory_file.close()
CVS_due_mandatory_file.close()
spitfire_late_mandatory_file.close()
spitfire_due_mandatory_file.close()
SCE_late_mandatory_file.close()
SCE_due_mandatory_file.close()
SCW_late_mandatory_file.close()
SCW_due_mandatory_file.close()
rea_late_mandatory_file.close()
rea_due_mandatory_file.close()
tame_late_mandatory_file.close()
tame_due_mandatory_file.close()
print("District reports finished!")
#Program
training_report()
districts_reports()