GDPR and missing training reports can now be produced.
This commit is contained in:
parent
c10c851586
commit
57af847546
@ -1,16 +1,16 @@
|
||||
#! python3
|
||||
#Training_Reports.py
|
||||
#A tool to process Compass Records and produce something human readable
|
||||
#Licence:
|
||||
#Licence: GPL-3.0-or-later
|
||||
#Written by Stuart Griffiths, stuart.griffiths@birminghamscouts.org.uk
|
||||
#Started 27/03/2022
|
||||
#Version:0.3
|
||||
#Version:0.4
|
||||
#Released:
|
||||
#Status: Working - outputs to 4 seperate CSV files
|
||||
#Status: Working
|
||||
#Inputs: CSV
|
||||
#Outputs: 4 x CSV
|
||||
#Outputs: multiple CSV
|
||||
#Next Steps: generate list of unique entries, upload to Drive?, retrive automatically, send e-mails, working directory selection,
|
||||
#Issues: View for mandatory learning is missing district and group info, need to cross reference - could solve through membership number filtering
|
||||
#Issues:
|
||||
#Background IP: https://automatetheboringstuff.com/, Chapter 16
|
||||
|
||||
#Notes - CSV Column Numbers
|
||||
@ -42,23 +42,9 @@ missing_file = open('missing_training.csv', 'w', newline='')
|
||||
missing = csv.writer(missing_file)
|
||||
missing.writerow(['Membership Number', 'Known Name', 'Surname', 'E-Mail', 'Role', 'Group', 'District', 'Uncompleted_Training_Module'])
|
||||
|
||||
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', 'Role', 'Group', 'District', 'Uncompleted_Training_Module', 'Due_Date'])
|
||||
|
||||
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', 'Role', 'Group', 'District', 'Uncompleted_Training_Module', 'Due_Date'])
|
||||
|
||||
getting_started_file = open('getting_started_training.csv', 'w', newline='')
|
||||
getting_started = csv.writer(getting_started_file)
|
||||
getting_started.writerow(['Membership Number', 'Known_Name', 'Surname', 'E-Mail', 'Role', 'Group', 'District', 'Uncompleted_Training_Module', 'Role_Start_Date'])
|
||||
|
||||
#text files
|
||||
#missing_training_list = open('_missing_training.txt', 'w')
|
||||
#late_mandatory_list = open('_late_mandatory_training.txt', 'w')
|
||||
#due_mandatory_list = open('_due_mandatory_training.txt', 'w')
|
||||
#getting_started_list = open('_getting_started_training.txt', 'w')
|
||||
GDPR_file = open('GDPR_training.csv', 'w', newline='')
|
||||
GDPR = csv.writer(GDPR_file)
|
||||
GDPR.writerow(['Membership Number', 'Known Name', 'Surname', 'E-Mail', 'Role', 'Group', 'District', 'Uncompleted_Training_Module'])
|
||||
|
||||
|
||||
#Modules
|
||||
@ -86,124 +72,171 @@ def training_report():
|
||||
if role_training == "":
|
||||
#If blank, add to list using known_name, surname, email, member_role, group, district, training module
|
||||
missing.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][14], input_data[line_num][12], input_data[line_num][16]])
|
||||
#missing_training_list.write(input_data[line_num][3] + ' ' + input_data[line_num][2]+' '+ input_data[line_num][4] + ' ' + input_data[line_num][5] + ' ' + input_data[line_num][14] + ' ' + input_data[line_num][12] + ' ' + input_data[line_num][16])
|
||||
#missing_training_list.write('\n') #adds new line
|
||||
#3.2 Test 2 - Are there any core modules to renew?
|
||||
#Read the column
|
||||
core_training = input_data[line_num][20]
|
||||
#Check - Is it not blank?
|
||||
if core_training != "":
|
||||
#Slice the chracters to get days, months and year (remember starts 0)
|
||||
dt = datetime.datetime.now() #need to call this to get current date
|
||||
core_training_year = int(core_training[6:])
|
||||
core_training_month1 = core_training[3:] #removes first 3 characters
|
||||
core_training_month = int(core_training_month1[:2]) #removes characters after first 2
|
||||
core_training_day = int(core_training[:2])
|
||||
#Check is it late?
|
||||
#If year is less than year when program is ran, add to list using known_name, surname, email, member_role, group, district, training module
|
||||
if core_training_year < dt.year:
|
||||
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][14], input_data[line_num][12], input_data[line_num][16], input_data[line_num][20]])
|
||||
#late_mandatory_list.write(input_data[line_num][3] + ' ' + input_data[line_num][2]+' '+ input_data[line_num][4] + ' ' + input_data[line_num][5] + ' ' + input_data[line_num][14] + ' ' + input_data[line_num][12] + ' ' + input_data[line_num][16] + ' ' + input_data[line_num][20])
|
||||
#late_mandatory_list.write('\n') #adds new line
|
||||
#Else if month is less than month when program is ran, add to list using known_name, surname, email, member_role, group, district, training module
|
||||
if core_training_month <= dt.month:
|
||||
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][14], input_data[line_num][12], input_data[line_num][16], input_data[line_num][20]])
|
||||
#late_mandatory_list.write(input_data[line_num][3] + ' ' + input_data[line_num][2]+' '+ input_data[line_num][4] + ' ' + input_data[line_num][5] + ' ' + input_data[line_num][14] + ' ' + input_data[line_num][12] + ' ' + input_data[line_num][16] + ' ' + input_data[line_num][20])
|
||||
#late_mandatory_list.write('\n') #adds new line
|
||||
#Else if year is less than year when program is ran, add to list using known_name, surname, email, member_role, group, district, training module
|
||||
if core_training_day <= dt.day:
|
||||
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][14], input_data[line_num][12], input_data[line_num][16], input_data[line_num][20]])
|
||||
#late_mandatory_list.write(input_data[line_num][3] + ' ' + input_data[line_num][2]+' '+ input_data[line_num][4] + ' ' + input_data[line_num][5] + ' ' + input_data[line_num][14] + ' ' + input_data[line_num][12] + ' ' + input_data[line_num][16] + ' ' + input_data[line_num][20])
|
||||
#late_mandatory_list.write('\n') #adds new line
|
||||
#Check - Is it due soon?
|
||||
#Establish comparative date - set at 6 months
|
||||
Xmonths_later = str(datetime.datetime.now() + relativedelta(months=+6))
|
||||
Xmonths_later_year = int(Xmonths_later[:4])
|
||||
Xmonths_later_month1 = Xmonths_later[5:] #removes first 3 characters
|
||||
Xmonths_later_month = int(Xmonths_later_month1[:2]) #removes characters after first 2
|
||||
Xmonths_later_day1 = Xmonths_later[8:]
|
||||
Xmonths_later_day = int(Xmonths_later_day1[:2])
|
||||
#If year is less than year when program is ran, add to list using known_name, surname, email, member_role, group, district, training module
|
||||
if core_training_year < Xmonths_later_year:
|
||||
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][14], input_data[line_num][12], input_data[line_num][16], input_data[line_num][20]])
|
||||
#due_mandatory_list.write(input_data[line_num][3] + ' ' + input_data[line_num][2]+' '+ input_data[line_num][4] + ' ' + input_data[line_num][5] + ' ' + input_data[line_num][14] + ' ' + input_data[line_num][12] + ' ' + input_data[line_num][16] + ' ' + input_data[line_num][20])
|
||||
#due_mandatory_list.write('\n') #adds new line
|
||||
#Else if month is less than month when program is ran, add to list using known_name, surname, email, member_role, group, district, training module
|
||||
if core_training_month <= Xmonths_later_month:
|
||||
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][14], input_data[line_num][12], input_data[line_num][16], input_data[line_num][20]])
|
||||
#due_mandatory_list.write(input_data[line_num][3] + ' ' + input_data[line_num][2]+' '+ input_data[line_num][4] + ' ' + input_data[line_num][5] + ' ' + input_data[line_num][14] + ' ' + input_data[line_num][12] + ' ' + input_data[line_num][16] + ' ' + input_data[line_num][20])
|
||||
#due_mandatory_list.write('\n') #adds new line
|
||||
#Else if year is less than year when program is ran, add to list using known_name, surname, email, member_role, group, district, training module
|
||||
if core_training_day <= Xmonths_later_day:
|
||||
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][14], input_data[line_num][12], input_data[line_num][16], input_data[line_num][20]])
|
||||
#due_mandatory_list.write(input_data[line_num][3] + ' ' + input_data[line_num][2]+' '+ input_data[line_num][4] + ' ' + input_data[line_num][5] + ' ' + input_data[line_num][14] + ' ' + input_data[line_num][12] + ' ' + input_data[line_num][16] + ' ' + input_data[line_num][20])
|
||||
#due_mandatory_list.write('\n') #adds new line
|
||||
#3.3 Test 3 - Have Getting Started Modules been completed?
|
||||
#GDPR, Essential Information, Trustee Introduction, Tools for the Role Section Leaders, Managers and Supporters
|
||||
|
||||
|
||||
#3.2 Test 2 - Missing GDPR?
|
||||
#GDPR
|
||||
#Check if Module is one we are interested in
|
||||
|
||||
module_name = str(input_data[line_num][16])
|
||||
if module_name == 'Essential Information':
|
||||
complete_check = str(input_data[line_num][17])
|
||||
#Check: is the date blank?
|
||||
if complete_check == '':
|
||||
getting_started.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][14], input_data[line_num][12], input_data[line_num][16], input_data[line_num][7]])
|
||||
#getting_started_list.write(input_data[line_num][3] + ' ' + input_data[line_num][2]+' '+ input_data[line_num][4] + ' ' + input_data[line_num][5] + ' ' + input_data[line_num][14] + ' ' + input_data[line_num][12] + ' ' + input_data[line_num][16] + ' ' + input_data[line_num][7])
|
||||
#getting_started_list.write('\n') #adds new line
|
||||
if module_name == 'General Data Protection Regulations':
|
||||
complete_check = str(input_data[line_num][17])
|
||||
#Check: is the date blank?
|
||||
if complete_check == '':
|
||||
getting_started.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][14], input_data[line_num][12], input_data[line_num][16], input_data[line_num][7]])
|
||||
#getting_started_list.write(input_data[line_num][3] + ' ' + input_data[line_num][2]+' '+ input_data[line_num][4] + ' ' + input_data[line_num][5] + ' ' + input_data[line_num][14] + ' ' + input_data[line_num][12] + ' ' + input_data[line_num][16] + ' ' + input_data[line_num][7])
|
||||
#getting_started_list.write('\n') #adds new line
|
||||
if module_name == 'Trustee Introduction':
|
||||
complete_check = str(input_data[line_num][17])
|
||||
#Check: is the date blank?
|
||||
if complete_check == '':
|
||||
getting_started.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][14], input_data[line_num][12], input_data[line_num][16], input_data[line_num][7]])
|
||||
#getting_started_list.write(input_data[line_num][3] + ' ' + input_data[line_num][2]+' '+ input_data[line_num][4] + ' ' + input_data[line_num][5] + ' ' + input_data[line_num][14] + ' ' + input_data[line_num][12] + ' ' + input_data[line_num][16] + ' ' + input_data[line_num][7])
|
||||
#getting_started_list.write('\n') #adds new line
|
||||
if module_name == 'Tools for the Role (Managers and Supporters)':
|
||||
complete_check = str(input_data[line_num][17])
|
||||
#Check: is the date blank?
|
||||
if complete_check == '':
|
||||
getting_started.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][14], input_data[line_num][12], input_data[line_num][16], input_data[line_num][7]])
|
||||
#getting_started_list.write(input_data[line_num][3] + ' ' + input_data[line_num][2]+' '+ input_data[line_num][4] + ' ' + input_data[line_num][5] + ' ' + input_data[line_num][14] + ' ' + input_data[line_num][12] + ' ' + input_data[line_num][16] + ' ' + input_data[line_num][7])
|
||||
#getting_started_list.write('\n') #adds new line
|
||||
if module_name == 'Tools for the Role (Section Leaders)':
|
||||
complete_check = str(input_data[line_num][17])
|
||||
#Check: is the date blank?
|
||||
if complete_check == '':
|
||||
getting_started.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][14], input_data[line_num][12], input_data[line_num][16], input_data[line_num][7]])
|
||||
#getting_started_list.write(input_data[line_num][3] + ' ' + input_data[line_num][2]+' '+ input_data[line_num][4] + ' ' + input_data[line_num][5] + ' ' + input_data[line_num][14] + ' ' + input_data[line_num][12] + ' ' + input_data[line_num][16] + ' ' + input_data[line_num][7])
|
||||
#getting_started_list.write('\n') #adds new line
|
||||
#Safety and Safeguarding
|
||||
module_name = str(input_data[16])
|
||||
if module_name == 'MOGL: Safeguarding':
|
||||
complete_check = str(input_data[line_num][20])
|
||||
#Check: is the date blank?
|
||||
if complete_check == '':
|
||||
getting_started.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][14], input_data[line_num][12], input_data[line_num][16], input_data[line_num][7]])
|
||||
#getting_started_list.write(input_data[line_num][3] + ' ' + input_data[line_num][2]+' '+ input_data[line_num][4] + ' ' + input_data[line_num][5] + ' ' + input_data[line_num][14] + ' ' + input_data[line_num][12] + ' ' + input_data[line_num][16] + ' ' + input_data[line_num][7])
|
||||
#getting_started_list.write('\n') #adds new line
|
||||
if module_name == 'MOGL: Safety':
|
||||
complete_check = str(input_data[line_num][20])
|
||||
#Check: is the date blank?
|
||||
if complete_check == '':
|
||||
getting_started.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][14], input_data[line_num][12], input_data[line_num][16], input_data[line_num][7]])
|
||||
#getting_started_list.write(input_data[line_num][3] + ' ' + input_data[line_num][2]+' '+ input_data[line_num][4] + ' ' + input_data[line_num][5] + ' ' + input_data[line_num][14] + ' ' + input_data[line_num][12] + ' ' + input_data[line_num][16] + ' ' + input_data[line_num][7])
|
||||
#getting_started_list.write('\n') #adds new line
|
||||
GDPR.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][14], input_data[line_num][12], input_data[line_num][16], input_data[line_num][7]])
|
||||
line_num = line_num + 1 #continues the loop
|
||||
#4: Close files to show they are done
|
||||
#missing_training_list.close()
|
||||
#late_mandatory_list.close()
|
||||
#due_mandatory_list.close()
|
||||
#getting_started_list.close()
|
||||
|
||||
missing_file.close()
|
||||
late_mandatory_file.close()
|
||||
due_mandatory_file.close()
|
||||
getting_started_file.close()
|
||||
print("Finished!")
|
||||
GDPR_file.close()
|
||||
print("Finished Total Reports!")
|
||||
|
||||
def districts_reports():
|
||||
#Runs after missing and soon due training has been listed. Produces district reports
|
||||
|
||||
#County
|
||||
|
||||
county_late_mandatory_file = open('county_missing_training.csv', 'w', newline='')
|
||||
county_late_mandatory = csv.writer(county_late_mandatory_file)
|
||||
county_late_mandatory.writerow(['Membership Number', 'Known Name', 'Surname', 'E-Mail', 'Role', 'Group', 'District', 'Uncompleted_Training_Module'])
|
||||
|
||||
county_GDPR_file = open('county_GDPR.csv', 'w', newline='')
|
||||
county_GDPR = csv.writer(county_GDPR_file)
|
||||
county_GDPR.writerow(['Membership Number', 'Known Name', 'Surname', 'E-Mail', 'Role', 'Group', 'District', 'Uncompleted_Training_Module'])
|
||||
|
||||
|
||||
#Districts
|
||||
|
||||
CVS_late_mandatory_file = open('CVS_missing_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_GDPR_file = open('CVS_GDPR.csv', 'w', newline='')
|
||||
CVS_GDPR = csv.writer(CVS_GDPR_file)
|
||||
CVS_GDPR.writerow(['Membership Number', 'Known Name', 'Surname', 'E-Mail', 'Role', 'Group', 'District', 'Uncompleted_Training_Module'])
|
||||
|
||||
spitfire_late_mandatory_file = open('spitfire_missing_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_GDPR_file = open('spitfire_GDPR.csv', 'w', newline='')
|
||||
spitfire_GDPR = csv.writer(spitfire_GDPR_file)
|
||||
spitfire_GDPR.writerow(['Membership Number', 'Known Name', 'Surname', 'E-Mail', 'Role', 'Group', 'District', 'Uncompleted_Training_Module'])
|
||||
|
||||
SCE_late_mandatory_file = open('SCE_missing_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_GDPR_file = open('SCE_GDPR.csv', 'w', newline='')
|
||||
SCE_GDPR = csv.writer(SCE_GDPR_file)
|
||||
SCE_GDPR.writerow(['Membership Number', 'Known Name', 'Surname', 'E-Mail', 'Role', 'Group', 'District', 'Uncompleted_Training_Module'])
|
||||
|
||||
SCW_late_mandatory_file = open('SCW_missing_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_GDPR_file = open('SCW_GDPR.csv', 'w', newline='')
|
||||
SCW_GDPR = csv.writer(SCW_GDPR_file)
|
||||
SCW_GDPR.writerow(['Membership Number', 'Known Name', 'Surname', 'E-Mail', 'Role', 'Group', 'District', 'Uncompleted_Training_Module'])
|
||||
|
||||
rea_late_mandatory_file = open('rea_missing_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_GDPR_file = open('rea_GDPR.csv', 'w', newline='')
|
||||
rea_GDPR = csv.writer(rea_GDPR_file)
|
||||
rea_GDPR.writerow(['Membership Number', 'Known Name', 'Surname', 'E-Mail', 'Role', 'Group', 'District', 'Uncompleted_Training_Module'])
|
||||
|
||||
tame_late_mandatory_file = open('tame_missing_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_GDPR_file = open('tame_GDPR.csv', 'w', newline='')
|
||||
tame_GDPR = csv.writer(tame_GDPR_file)
|
||||
tame_GDPR.writerow(['Membership Number', 'Known Name', 'Surname', 'E-Mail', 'Role', 'Group', 'District', 'Uncompleted_Training_Module'])
|
||||
|
||||
#6. late reports
|
||||
#Open the file
|
||||
file_name = str(Path.cwd()) + '/' + str('missing_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 (6)
|
||||
district = input_data[line_num][6]
|
||||
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]])
|
||||
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]])
|
||||
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]])
|
||||
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]])
|
||||
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]])
|
||||
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]])
|
||||
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]])
|
||||
|
||||
line_num = line_num + 1
|
||||
|
||||
#7. late reports
|
||||
#Open the file
|
||||
file_name = str(Path.cwd()) + '/' + str('GDPR_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 (6)
|
||||
district = input_data[line_num][6]
|
||||
if district == '':
|
||||
#If no district, must be county
|
||||
county_GDPR.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]])
|
||||
if district == 'Cole Valley South':
|
||||
CVS_GDPR.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]])
|
||||
if district == 'Birmingham Spitfire District Scout Association':
|
||||
spitfire_GDPR.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]])
|
||||
if district == 'Sutton Coldfield East':
|
||||
SCE_GDPR.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]])
|
||||
if district == 'Sutton Coldfield West':
|
||||
SCW_GDPR.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]])
|
||||
if district == 'Rea Valley':
|
||||
rea_GDPR.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]])
|
||||
if district == 'Tame Valley Birmingham':
|
||||
tame_GDPR.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]])
|
||||
|
||||
line_num = line_num + 1 #continues the loop
|
||||
|
||||
#8: Close the files
|
||||
county_late_mandatory_file.close()
|
||||
county_GDPR_file.close()
|
||||
CVS_late_mandatory_file.close()
|
||||
CVS_GDPR_file.close()
|
||||
spitfire_late_mandatory_file.close()
|
||||
spitfire_GDPR_file.close()
|
||||
SCE_late_mandatory_file.close()
|
||||
SCE_GDPR_file.close()
|
||||
SCW_late_mandatory_file.close()
|
||||
SCW_GDPR_file.close()
|
||||
rea_late_mandatory_file.close()
|
||||
rea_GDPR_file.close()
|
||||
tame_late_mandatory_file.close()
|
||||
tame_GDPR_file.close()
|
||||
|
||||
print("District reports finised!")
|
||||
|
||||
#Program
|
||||
training_report()
|
||||
districts_reports()
|
||||
|
Loading…
Reference in New Issue
Block a user