scouts_training_reports/convert_csv_xlsx.py

706 lines
31 KiB
Python

#! python3
#convert_csv_xlsx.py
#A tool to change CSVs to XLSX
#Licence: GPL-3.0-or-later
#Written by Stuart Griffiths, stuart.griffiths@birminghamscouts.org.uk
#Started 02/07/2022
#Version:0.2
#Released: 31/07/2022
#Status: Working
#Inputs: CSVs
#Outputs: XLSXs, zip files, folder
#Additional modules: openpyxl, pyminizip
#Next Steps:
#Issues:
#Background IP:
#Libraries
import os #Enables file IO
from pathlib import Path #to work out current working directory
import csv #required to handle csv files
import pandas as pd #required to convert CSV to XLSX
import shutil #required for shell functions
import datetime #required for getting today's date
import pyminizip #required to zip a file up with password
def convert_csv_xlsx():
#for every file ending in .csv
#for files in os.walk(Path.cwd()):
# for file_path in files:
# extensions = ('.csv')
# ext = os.path.splitext(file_path)[1]
# if ext in extensions:
# file_name = os.path.splitext(file_path)[0]
# print(file_name)
#read_file = pd.read_csv(file)
# read_file.to_excel(file + '.xlsx')
#1 - make working folder
#get today's date
today1 = str(datetime.date.today())
today = datetime.datetime.strptime(today1, "%Y-%m-%d") #dodgy work around comparing datetime to date object error
working_folder = str(Path.cwd()) + '/' + str(today)
os.makedirs(working_folder)
#make district folders
county_folder = working_folder + '/' + 'county'
os.makedirs(county_folder)
CVS_folder = working_folder + '/' + 'CVS'
os.makedirs(CVS_folder)
rea_folder = working_folder + '/' + 'rea'
os.makedirs(rea_folder)
SCE_folder = working_folder + '/' + 'SCE'
os.makedirs(SCE_folder)
SCW_folder = working_folder + '/' + 'SCW'
os.makedirs(SCW_folder)
spitfire_folder = working_folder + '/' + 'spitfire'
os.makedirs(spitfire_folder)
tame_folder = working_folder + '/' + 'tame'
os.makedirs(tame_folder)
csv_folder = working_folder + '/' + '_csv'
os.makedirs(csv_folder)
#2 - GDPR
#get paths and file name
file_title = 'county_GDPR'
folder_name = county_folder
file_name = str(Path.cwd()) + '/' + str(file_title + '.csv')
#convert to xlsx
read_file = pd.read_csv(file_name)
file_name_xlsx = file_title + '.xlsx'
read_file.to_excel(file_name_xlsx, index = None, header = True)
#move file to the right place
file_name_destination = folder_name + '/' + file_name_xlsx
shutil.move(file_name_xlsx, file_name_destination)
#move the CSV to the right place
csv_destination = csv_folder + '/' + str(file_title + '.csv')
shutil.move(file_name, csv_destination)
#get paths and file name
file_title = 'CVS_GDPR'
folder_name = CVS_folder
file_name = str(Path.cwd()) + '/' + str(file_title + '.csv')
#convert to xlsx
read_file = pd.read_csv(file_name)
file_name_xlsx = file_title + '.xlsx'
read_file.to_excel(file_name_xlsx, index = None, header = True)
#move file to the right place
file_name_destination = folder_name + '/' + file_name_xlsx
shutil.move(file_name_xlsx, file_name_destination)
#move the CSV to the right place
csv_destination = csv_folder + '/' + str(file_title + '.csv')
shutil.move(file_name, csv_destination)
#get paths and file name
file_title = 'rea_GDPR'
folder_name = rea_folder
file_name = str(Path.cwd()) + '/' + str(file_title + '.csv')
#convert to xlsx
read_file = pd.read_csv(file_name)
file_name_xlsx = file_title + '.xlsx'
read_file.to_excel(file_name_xlsx, index = None, header = True)
#move file to the right place
file_name_destination = folder_name + '/' + file_name_xlsx
shutil.move(file_name_xlsx, file_name_destination)
#move the CSV to the right place
csv_destination = csv_folder + '/' + str(file_title + '.csv')
shutil.move(file_name, csv_destination)
#get paths and file name
file_title = 'SCE_GDPR'
folder_name = SCE_folder
file_name = str(Path.cwd()) + '/' + str(file_title + '.csv')
#convert to xlsx
read_file = pd.read_csv(file_name)
file_name_xlsx = file_title + '.xlsx'
read_file.to_excel(file_name_xlsx, index = None, header = True)
#move file to the right place
file_name_destination = folder_name + '/' + file_name_xlsx
shutil.move(file_name_xlsx, file_name_destination)
#move the CSV to the right place
csv_destination = csv_folder + '/' + str(file_title + '.csv')
shutil.move(file_name, csv_destination)
#get paths and file name
file_title = 'SCW_GDPR'
folder_name = SCW_folder
file_name = str(Path.cwd()) + '/' + str(file_title + '.csv')
#convert to xlsx
read_file = pd.read_csv(file_name)
file_name_xlsx = file_title + '.xlsx'
read_file.to_excel(file_name_xlsx, index = None, header = True)
#move file to the right place
file_name_destination = folder_name + '/' + file_name_xlsx
shutil.move(file_name_xlsx, file_name_destination)
#move the CSV to the right place
csv_destination = csv_folder + '/' + str(file_title + '.csv')
shutil.move(file_name, csv_destination)
#get paths and file name
file_title = 'spitfire_GDPR'
folder_name = spitfire_folder
file_name = str(Path.cwd()) + '/' + str(file_title + '.csv')
#convert to xlsx
read_file = pd.read_csv(file_name)
file_name_xlsx = file_title + '.xlsx'
read_file.to_excel(file_name_xlsx, index = None, header = True)
#move file to the right place
file_name_destination = folder_name + '/' + file_name_xlsx
shutil.move(file_name_xlsx, file_name_destination)
#move the CSV to the right place
csv_destination = csv_folder + '/' + str(file_title + '.csv')
shutil.move(file_name, csv_destination)
#get paths and file name
file_title = 'tame_GDPR'
folder_name = tame_folder
file_name = str(Path.cwd()) + '/' + str(file_title + '.csv')
#convert to xlsx
read_file = pd.read_csv(file_name)
file_name_xlsx = file_title + '.xlsx'
read_file.to_excel(file_name_xlsx, index = None, header = True)
#move file to the right place
file_name_destination = folder_name + '/' + file_name_xlsx
shutil.move(file_name_xlsx, file_name_destination)
#move the CSV to the right place
csv_destination = csv_folder + '/' + str(file_title + '.csv')
shutil.move(file_name, csv_destination)
#3 - Due Mandatory Training
#get paths and file name
file_title = 'county_due_mandatory_training'
folder_name = county_folder
file_name = str(Path.cwd()) + '/' + str(file_title + '.csv')
#convert to xlsx
read_file = pd.read_csv(file_name)
file_name_xlsx = file_title + '.xlsx'
read_file.to_excel(file_name_xlsx, index = None, header = True)
#move file to the right place
file_name_destination = folder_name + '/' + file_name_xlsx
shutil.move(file_name_xlsx, file_name_destination)
#move the CSV to the right place
csv_destination = csv_folder + '/' + str(file_title + '.csv')
shutil.move(file_name, csv_destination)
#get paths and file name
file_title = 'CVS_due_mandatory_training'
folder_name = CVS_folder
file_name = str(Path.cwd()) + '/' + str(file_title + '.csv')
#convert to xlsx
read_file = pd.read_csv(file_name)
file_name_xlsx = file_title + '.xlsx'
read_file.to_excel(file_name_xlsx, index = None, header = True)
#move file to the right place
file_name_destination = folder_name + '/' + file_name_xlsx
shutil.move(file_name_xlsx, file_name_destination)
#move the CSV to the right place
csv_destination = csv_folder + '/' + str(file_title + '.csv')
shutil.move(file_name, csv_destination)
#get paths and file name
file_title = 'rea_due_mandatory_training'
folder_name = rea_folder
file_name = str(Path.cwd()) + '/' + str(file_title + '.csv')
#convert to xlsx
read_file = pd.read_csv(file_name)
file_name_xlsx = file_title + '.xlsx'
read_file.to_excel(file_name_xlsx, index = None, header = True)
#move file to the right place
file_name_destination = folder_name + '/' + file_name_xlsx
shutil.move(file_name_xlsx, file_name_destination)
#move the CSV to the right place
csv_destination = csv_folder + '/' + str(file_title + '.csv')
shutil.move(file_name, csv_destination)
#get paths and file name
file_title = 'SCE_due_mandatory_training'
folder_name = SCE_folder
file_name = str(Path.cwd()) + '/' + str(file_title + '.csv')
#convert to xlsx
read_file = pd.read_csv(file_name)
file_name_xlsx = file_title + '.xlsx'
read_file.to_excel(file_name_xlsx, index = None, header = True)
#move file to the right place
file_name_destination = folder_name + '/' + file_name_xlsx
shutil.move(file_name_xlsx, file_name_destination)
#move the CSV to the right place
csv_destination = csv_folder + '/' + str(file_title + '.csv')
shutil.move(file_name, csv_destination)
#get paths and file name
file_title = 'SCW_due_mandatory_training'
folder_name = SCW_folder
file_name = str(Path.cwd()) + '/' + str(file_title + '.csv')
#convert to xlsx
read_file = pd.read_csv(file_name)
file_name_xlsx = file_title + '.xlsx'
read_file.to_excel(file_name_xlsx, index = None, header = True)
#move file to the right place
file_name_destination = folder_name + '/' + file_name_xlsx
shutil.move(file_name_xlsx, file_name_destination)
#move the CSV to the right place
csv_destination = csv_folder + '/' + str(file_title + '.csv')
shutil.move(file_name, csv_destination)
#get paths and file name
file_title = 'spitfire_due_mandatory_training'
folder_name = spitfire_folder
file_name = str(Path.cwd()) + '/' + str(file_title + '.csv')
#convert to xlsx
read_file = pd.read_csv(file_name)
file_name_xlsx = file_title + '.xlsx'
read_file.to_excel(file_name_xlsx, index = None, header = True)
#move file to the right place
file_name_destination = folder_name + '/' + file_name_xlsx
shutil.move(file_name_xlsx, file_name_destination)
#move the CSV to the right place
csv_destination = csv_folder + '/' + str(file_title + '.csv')
shutil.move(file_name, csv_destination)
#get paths and file name
file_title = 'tame_due_mandatory_training'
folder_name = tame_folder
file_name = str(Path.cwd()) + '/' + str(file_title + '.csv')
#convert to xlsx
read_file = pd.read_csv(file_name)
file_name_xlsx = file_title + '.xlsx'
read_file.to_excel(file_name_xlsx, index = None, header = True)
#move file to the right place
file_name_destination = folder_name + '/' + file_name_xlsx
shutil.move(file_name_xlsx, file_name_destination)
#move the CSV to the right place
csv_destination = csv_folder + '/' + str(file_title + '.csv')
shutil.move(file_name, csv_destination)
#4 - Late Mandatory Training
#get paths and file name
file_title = 'county_late_mandatory_training'
folder_name = county_folder
file_name = str(Path.cwd()) + '/' + str(file_title + '.csv')
#convert to xlsx
read_file = pd.read_csv(file_name)
file_name_xlsx = file_title + '.xlsx'
read_file.to_excel(file_name_xlsx, index = None, header = True)
#move file to the right place
file_name_destination = folder_name + '/' + file_name_xlsx
shutil.move(file_name_xlsx, file_name_destination)
#move the CSV to the right place
csv_destination = csv_folder + '/' + str(file_title + '.csv')
shutil.move(file_name, csv_destination)
#get paths and file name
file_title = 'CVS_late_mandatory_training'
folder_name = CVS_folder
file_name = str(Path.cwd()) + '/' + str(file_title + '.csv')
#convert to xlsx
read_file = pd.read_csv(file_name)
file_name_xlsx = file_title + '.xlsx'
read_file.to_excel(file_name_xlsx, index = None, header = True)
#move file to the right place
file_name_destination = folder_name + '/' + file_name_xlsx
shutil.move(file_name_xlsx, file_name_destination)
#move the CSV to the right place
csv_destination = csv_folder + '/' + str(file_title + '.csv')
shutil.move(file_name, csv_destination)
#get paths and file name
file_title = 'rea_late_mandatory_training'
folder_name = rea_folder
file_name = str(Path.cwd()) + '/' + str(file_title + '.csv')
#convert to xlsx
read_file = pd.read_csv(file_name)
file_name_xlsx = file_title + '.xlsx'
read_file.to_excel(file_name_xlsx, index = None, header = True)
#move file to the right place
file_name_destination = folder_name + '/' + file_name_xlsx
shutil.move(file_name_xlsx, file_name_destination)
#move the CSV to the right place
csv_destination = csv_folder + '/' + str(file_title + '.csv')
shutil.move(file_name, csv_destination)
#get paths and file name
file_title = 'SCE_late_mandatory_training'
folder_name = SCE_folder
file_name = str(Path.cwd()) + '/' + str(file_title + '.csv')
#convert to xlsx
read_file = pd.read_csv(file_name)
file_name_xlsx = file_title + '.xlsx'
read_file.to_excel(file_name_xlsx, index = None, header = True)
#move file to the right place
file_name_destination = folder_name + '/' + file_name_xlsx
shutil.move(file_name_xlsx, file_name_destination)
#move the CSV to the right place
csv_destination = csv_folder + '/' + str(file_title + '.csv')
shutil.move(file_name, csv_destination)
#get paths and file name
file_title = 'SCW_late_mandatory_training'
folder_name = SCW_folder
file_name = str(Path.cwd()) + '/' + str(file_title + '.csv')
#convert to xlsx
read_file = pd.read_csv(file_name)
file_name_xlsx = file_title + '.xlsx'
read_file.to_excel(file_name_xlsx, index = None, header = True)
#move file to the right place
file_name_destination = folder_name + '/' + file_name_xlsx
shutil.move(file_name_xlsx, file_name_destination)
#move the CSV to the right place
csv_destination = csv_folder + '/' + str(file_title + '.csv')
shutil.move(file_name, csv_destination)
#get paths and file name
file_title = 'spitfire_late_mandatory_training'
folder_name = spitfire_folder
file_name = str(Path.cwd()) + '/' + str(file_title + '.csv')
#convert to xlsx
read_file = pd.read_csv(file_name)
file_name_xlsx = file_title + '.xlsx'
read_file.to_excel(file_name_xlsx, index = None, header = True)
#move file to the right place
file_name_destination = folder_name + '/' + file_name_xlsx
shutil.move(file_name_xlsx, file_name_destination)
#move the CSV to the right place
csv_destination = csv_folder + '/' + str(file_title + '.csv')
shutil.move(file_name, csv_destination)
#get paths and file name
file_title = 'tame_late_mandatory_training'
folder_name = tame_folder
file_name = str(Path.cwd()) + '/' + str(file_title + '.csv')
#convert to xlsx
read_file = pd.read_csv(file_name)
file_name_xlsx = file_title + '.xlsx'
read_file.to_excel(file_name_xlsx, index = None, header = True)
#move file to the right place
file_name_destination = folder_name + '/' + file_name_xlsx
shutil.move(file_name_xlsx, file_name_destination)
#move the CSV to the right place
csv_destination = csv_folder + '/' + str(file_title + '.csv')
shutil.move(file_name, csv_destination)
#5 - GDPR
#get paths and file name
file_title = 'county_missing_training'
folder_name = county_folder
file_name = str(Path.cwd()) + '/' + str(file_title + '.csv')
#convert to xlsx
read_file = pd.read_csv(file_name)
file_name_xlsx = file_title + '.xlsx'
read_file.to_excel(file_name_xlsx, index = None, header = True)
#move file to the right place
file_name_destination = folder_name + '/' + file_name_xlsx
shutil.move(file_name_xlsx, file_name_destination)
#move the CSV to the right place
csv_destination = csv_folder + '/' + str(file_title + '.csv')
shutil.move(file_name, csv_destination)
#get paths and file name
file_title = 'CVS_missing_training'
folder_name = CVS_folder
file_name = str(Path.cwd()) + '/' + str(file_title + '.csv')
#convert to xlsx
read_file = pd.read_csv(file_name)
file_name_xlsx = file_title + '.xlsx'
read_file.to_excel(file_name_xlsx, index = None, header = True)
#move file to the right place
file_name_destination = folder_name + '/' + file_name_xlsx
shutil.move(file_name_xlsx, file_name_destination)
#move the CSV to the right place
csv_destination = csv_folder + '/' + str(file_title + '.csv')
shutil.move(file_name, csv_destination)
#get paths and file name
file_title = 'rea_missing_training'
folder_name = rea_folder
file_name = str(Path.cwd()) + '/' + str(file_title + '.csv')
#convert to xlsx
read_file = pd.read_csv(file_name)
file_name_xlsx = file_title + '.xlsx'
read_file.to_excel(file_name_xlsx, index = None, header = True)
#move file to the right place
file_name_destination = folder_name + '/' + file_name_xlsx
shutil.move(file_name_xlsx, file_name_destination)
#move the CSV to the right place
csv_destination = csv_folder + '/' + str(file_title + '.csv')
shutil.move(file_name, csv_destination)
#get paths and file name
file_title = 'SCE_missing_training'
folder_name = SCE_folder
file_name = str(Path.cwd()) + '/' + str(file_title + '.csv')
#convert to xlsx
read_file = pd.read_csv(file_name)
file_name_xlsx = file_title + '.xlsx'
read_file.to_excel(file_name_xlsx, index = None, header = True)
#move file to the right place
file_name_destination = folder_name + '/' + file_name_xlsx
shutil.move(file_name_xlsx, file_name_destination)
#move the CSV to the right place
csv_destination = csv_folder + '/' + str(file_title + '.csv')
shutil.move(file_name, csv_destination)
#get paths and file name
file_title = 'SCW_missing_training'
folder_name = SCW_folder
file_name = str(Path.cwd()) + '/' + str(file_title + '.csv')
#convert to xlsx
read_file = pd.read_csv(file_name)
file_name_xlsx = file_title + '.xlsx'
read_file.to_excel(file_name_xlsx, index = None, header = True)
#move file to the right place
file_name_destination = folder_name + '/' + file_name_xlsx
shutil.move(file_name_xlsx, file_name_destination)
#move the CSV to the right place
csv_destination = csv_folder + '/' + str(file_title + '.csv')
shutil.move(file_name, csv_destination)
#get paths and file name
file_title = 'spitfire_missing_training'
folder_name = spitfire_folder
file_name = str(Path.cwd()) + '/' + str(file_title + '.csv')
#convert to xlsx
read_file = pd.read_csv(file_name)
file_name_xlsx = file_title + '.xlsx'
read_file.to_excel(file_name_xlsx, index = None, header = True)
#move file to the right place
file_name_destination = folder_name + '/' + file_name_xlsx
shutil.move(file_name_xlsx, file_name_destination)
#move the CSV to the right place
csv_destination = csv_folder + '/' + str(file_title + '.csv')
shutil.move(file_name, csv_destination)
#get paths and file name
file_title = 'tame_missing_training'
folder_name = tame_folder
file_name = str(Path.cwd()) + '/' + str(file_title + '.csv')
#convert to xlsx
read_file = pd.read_csv(file_name)
file_name_xlsx = file_title + '.xlsx'
read_file.to_excel(file_name_xlsx, index = None, header = True)
#move file to the right place
file_name_destination = folder_name + '/' + file_name_xlsx
shutil.move(file_name_xlsx, file_name_destination)
#move the CSV to the right place
csv_destination = csv_folder + '/' + str(file_title + '.csv')
shutil.move(file_name, csv_destination)
#6 - Woodbadge Reports
#get paths and file name
file_title = 'county_woodbadge_training'
folder_name = county_folder
file_name = str(Path.cwd()) + '/' + str(file_title + '.csv')
#convert to xlsx
read_file = pd.read_csv(file_name)
file_name_xlsx = file_title + '.xlsx'
read_file.to_excel(file_name_xlsx, index = None, header = True)
#move file to the right place
file_name_destination = folder_name + '/' + file_name_xlsx
shutil.move(file_name_xlsx, file_name_destination)
#move the CSV to the right place
csv_destination = csv_folder + '/' + str(file_title + '.csv')
shutil.move(file_name, csv_destination)
#get paths and file name
file_title = 'CVS_woodbadge_training'
folder_name = CVS_folder
file_name = str(Path.cwd()) + '/' + str(file_title + '.csv')
#convert to xlsx
read_file = pd.read_csv(file_name)
file_name_xlsx = file_title + '.xlsx'
read_file.to_excel(file_name_xlsx, index = None, header = True)
#move file to the right place
file_name_destination = folder_name + '/' + file_name_xlsx
shutil.move(file_name_xlsx, file_name_destination)
#move the CSV to the right place
csv_destination = csv_folder + '/' + str(file_title + '.csv')
shutil.move(file_name, csv_destination)
#get paths and file name
file_title = 'rea_woodbadge_training'
folder_name = rea_folder
file_name = str(Path.cwd()) + '/' + str(file_title + '.csv')
#convert to xlsx
read_file = pd.read_csv(file_name)
file_name_xlsx = file_title + '.xlsx'
read_file.to_excel(file_name_xlsx, index = None, header = True)
#move file to the right place
file_name_destination = folder_name + '/' + file_name_xlsx
shutil.move(file_name_xlsx, file_name_destination)
#move the CSV to the right place
csv_destination = csv_folder + '/' + str(file_title + '.csv')
shutil.move(file_name, csv_destination)
#get paths and file name
file_title = 'SCE_woodbadge_training'
folder_name = SCE_folder
file_name = str(Path.cwd()) + '/' + str(file_title + '.csv')
#convert to xlsx
read_file = pd.read_csv(file_name)
file_name_xlsx = file_title + '.xlsx'
read_file.to_excel(file_name_xlsx, index = None, header = True)
#move file to the right place
file_name_destination = folder_name + '/' + file_name_xlsx
shutil.move(file_name_xlsx, file_name_destination)
#move the CSV to the right place
csv_destination = csv_folder + '/' + str(file_title + '.csv')
shutil.move(file_name, csv_destination)
#get paths and file name
file_title = 'SCW_woodbadge_training'
folder_name = SCW_folder
file_name = str(Path.cwd()) + '/' + str(file_title + '.csv')
#convert to xlsx
read_file = pd.read_csv(file_name)
file_name_xlsx = file_title + '.xlsx'
read_file.to_excel(file_name_xlsx, index = None, header = True)
#move file to the right place
file_name_destination = folder_name + '/' + file_name_xlsx
shutil.move(file_name_xlsx, file_name_destination)
#move the CSV to the right place
csv_destination = csv_folder + '/' + str(file_title + '.csv')
shutil.move(file_name, csv_destination)
#get paths and file name
file_title = 'spitfire_woodbadge_training'
folder_name = spitfire_folder
file_name = str(Path.cwd()) + '/' + str(file_title + '.csv')
#convert to xlsx
read_file = pd.read_csv(file_name)
file_name_xlsx = file_title + '.xlsx'
read_file.to_excel(file_name_xlsx, index = None, header = True)
#move file to the right place
file_name_destination = folder_name + '/' + file_name_xlsx
shutil.move(file_name_xlsx, file_name_destination)
#move the CSV to the right place
csv_destination = csv_folder + '/' + str(file_title + '.csv')
shutil.move(file_name, csv_destination)
#get paths and file name
file_title = 'tame_woodbadge_training'
folder_name = tame_folder
file_name = str(Path.cwd()) + '/' + str(file_title + '.csv')
#convert to xlsx
read_file = pd.read_csv(file_name)
file_name_xlsx = file_title + '.xlsx'
read_file.to_excel(file_name_xlsx, index = None, header = True)
#move file to the right place
file_name_destination = folder_name + '/' + file_name_xlsx
shutil.move(file_name_xlsx, file_name_destination)
#move the CSV to the right place
csv_destination = csv_folder + '/' + str(file_title + '.csv')
shutil.move(file_name, csv_destination)
#7 - General
file_title = 'due_mandatory_training'
folder_name = working_folder
file_name = str(Path.cwd()) + '/' + str(file_title + '.csv')
#convert to xlsx
read_file = pd.read_csv(file_name)
file_name_xlsx = file_title + '.xlsx'
read_file.to_excel(file_name_xlsx, index = None, header = True)
#move file to the right place
file_name_destination = folder_name + '/' + file_name_xlsx
shutil.move(file_name_xlsx, file_name_destination)
#move the CSV to the right place
csv_destination = csv_folder + '/' + str(file_title + '.csv')
shutil.move(file_name, csv_destination)
file_title = 'missing_training'
folder_name = working_folder
file_name = str(Path.cwd()) + '/' + str(file_title + '.csv')
#convert to xlsx
read_file = pd.read_csv(file_name)
file_name_xlsx = file_title + '.xlsx'
read_file.to_excel(file_name_xlsx, index = None, header = True)
#move file to the right place
file_name_destination = folder_name + '/' + file_name_xlsx
shutil.move(file_name_xlsx, file_name_destination)
#move the CSV to the right place
csv_destination = csv_folder + '/' + str(file_title + '.csv')
shutil.move(file_name, csv_destination)
file_title = 'GDPR_training'
folder_name = working_folder
file_name = str(Path.cwd()) + '/' + str(file_title + '.csv')
#convert to xlsx
read_file = pd.read_csv(file_name)
file_name_xlsx = file_title + '.xlsx'
read_file.to_excel(file_name_xlsx, index = None, header = True)
#move file to the right place
file_name_destination = folder_name + '/' + file_name_xlsx
shutil.move(file_name_xlsx, file_name_destination)
#move the CSV to the right place
csv_destination = csv_folder + '/' + str(file_title + '.csv')
shutil.move(file_name, csv_destination)
file_title = 'late_mandatory_training'
folder_name = working_folder
file_name = str(Path.cwd()) + '/' + str(file_title + '.csv')
#convert to xlsx
read_file = pd.read_csv(file_name)
file_name_xlsx = file_title + '.xlsx'
read_file.to_excel(file_name_xlsx, index = None, header = True)
#move file to the right place
file_name_destination = folder_name + '/' + file_name_xlsx
shutil.move(file_name_xlsx, file_name_destination)
#move the CSV to the right place
csv_destination = csv_folder + '/' + str(file_title + '.csv')
shutil.move(file_name, csv_destination)
file_title = 'woodbadge_report'
folder_name = working_folder
file_name = str(Path.cwd()) + '/' + str(file_title + '.csv')
#convert to xlsx
read_file = pd.read_csv(file_name)
file_name_xlsx = file_title + '.xlsx'
read_file.to_excel(file_name_xlsx, index = None, header = True)
#move file to the right place
file_name_destination = folder_name + '/' + file_name_xlsx
shutil.move(file_name_xlsx, file_name_destination)
#move the CSV to the right place
csv_destination = csv_folder + '/' + str(file_title + '.csv')
shutil.move(file_name, csv_destination)
#8 - Stats files
file_title = '_GDPR_statistics.txt'
folder_name = working_folder
file_name = str(Path.cwd()) + '/' + str(file_title)
#move file to the right place
file_name_destination = folder_name + '/' + file_title
shutil.move(file_name, file_name_destination)
file_title = '_total_training_statistics.txt'
folder_name = working_folder
file_name = str(Path.cwd()) + '/' + str(file_title)
#move file to the right place
file_name_destination = folder_name + '/' + file_title
shutil.move(file_name, file_name_destination)
file_title = '_woodbadge_statistics.txt'
folder_name = working_folder
file_name = str(Path.cwd()) + '/' + str(file_title)
#move file to the right place
file_name_destination = folder_name + '/' + file_title
shutil.move(file_name, file_name_destination)
#9 - zip files
#make list of files to zip
county_list = [str(county_folder) + '/' + 'county_due_mandatory_training.xlsx', str(county_folder) + '/' + 'county_late_mandatory_training.xlsx', str(county_folder) + '/' + 'county_missing_training.xlsx', str(county_folder) + '/' + 'county_GDPR.xlsx', str(county_folder) + '/' + 'county_woodbadge_training.xlsx']
CVS_list = [str(CVS_folder) + '/' + 'CVS_due_mandatory_training.xlsx', str(CVS_folder) + '/' + 'CVS_late_mandatory_training.xlsx', str(CVS_folder) + '/' + 'CVS_missing_training.xlsx', str(CVS_folder) + '/' + 'CVS_GDPR.xlsx', str(CVS_folder) + '/' + 'CVS_woodbadge_training.xlsx']
rea_list = [str(rea_folder) + '/' + 'rea_due_mandatory_training.xlsx', str(rea_folder) + '/' + 'rea_late_mandatory_training.xlsx', str(rea_folder) + '/' + 'rea_missing_training.xlsx', str(rea_folder) + '/' + 'rea_GDPR.xlsx', str(rea_folder) + '/' + 'rea_woodbadge_training.xlsx']
SCE_list = [str(SCE_folder) + '/' + 'SCE_due_mandatory_training.xlsx', str(SCE_folder) + '/' + 'SCE_late_mandatory_training.xlsx', str(SCE_folder) + '/' + 'SCE_missing_training.xlsx', str(SCE_folder) + '/' + 'SCE_GDPR.xlsx', str(SCE_folder) + '/' + 'SCE_woodbadge_training.xlsx']
SCW_list = [str(SCW_folder) + '/' + 'SCW_due_mandatory_training.xlsx', str(SCW_folder) + '/' + 'SCW_late_mandatory_training.xlsx', str(SCW_folder) + '/' + 'SCW_missing_training.xlsx', str(SCW_folder) + '/' + 'SCW_GDPR.xlsx', str(SCW_folder) + '/' + 'SCW_woodbadge_training.xlsx']
spitfire_list = [str(spitfire_folder) + '/' + 'spitfire_due_mandatory_training.xlsx', str(spitfire_folder) + '/' + 'spitfire_late_mandatory_training.xlsx', str(spitfire_folder) + '/' + 'spitfire_missing_training.xlsx', str(spitfire_folder) + '/' + 'spitfire_GDPR.xlsx', str(spitfire_folder) + '/' + 'spitfire_woodbadge_training.xlsx']
tame_list = [str(tame_folder) + '/' + 'tame_due_mandatory_training.xlsx', str(tame_folder) + '/' + 'tame_late_mandatory_training.xlsx', str(tame_folder) + '/' + 'tame_missing_training.xlsx', str(tame_folder) + '/' + 'tame_GDPR.xlsx', str(tame_folder) + '/' + 'tame_woodbadge_training.xlsx']
#zip away
pyminizip.compress_multiple(county_list, [], str(working_folder) + '/' + "county.zip", "BhamSc@uts", 1)
pyminizip.compress_multiple(CVS_list, [], str(working_folder) + '/' + "CVS.zip", "BhamSc@uts", 1)
pyminizip.compress_multiple(rea_list, [], str(working_folder) + '/' + "rea.zip", "BhamSc@uts", 1)
pyminizip.compress_multiple(SCE_list, [], str(working_folder) + '/' + "SCE.zip", "BhamSc@uts", 1)
pyminizip.compress_multiple(SCW_list, [], str(working_folder) + '/' + "SCW.zip", "BhamSc@uts", 1)
pyminizip.compress_multiple(spitfire_list, [], str(working_folder) + '/' + "spitfire.zip", "BhamSc@uts", 1)
pyminizip.compress_multiple(tame_list, [], str(working_folder) + '/' + "tame.zip", "BhamSc@uts", 1)
print("Folder sorting and zipping completed!")
convert_csv_xlsx()