Created
January 11, 2022 22:26
-
-
Save johntfoster/6d331aca6467e1b4771160d131a2759b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env julia | |
#Copyright 2022 John T. Foster | |
# | |
#Permission is hereby granted, free of charge, to any person obtaining a copy of | |
#this software and associated documentation files (the "Software"), to deal in | |
#the Software without restriction, including without limitation the rights to | |
#use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | |
#of the Software, and to permit persons to whom the Software is furnished to | |
#do so, subject to the following conditions: | |
# | |
#The above copyright notice and this permission notice shall be included in all | |
#copies or substantial portions of the Software. | |
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
#SOFTWARE. | |
# | |
#https://preppindata.blogspot.com/2022/01/2022-week-1-prep-school-parental.html | |
using CSV | |
using DataFrames | |
using Dates | |
function parse() | |
raw_df = CSV.read("PD 2022 Wk 1 Input - Input.csv", DataFrame) | |
out_df = DataFrame() | |
out_df[:, "Academic Year"] = ceil.(Int, Dates.value.(Date(2014, 9, 1) .- | |
Date.(raw_df[:, "Date of Birth"], | |
dateformat"m/d/y")) / | |
365.25 .+ 1) | |
out_df[!, "Pupil's Name"] = (raw_df[!, "pupil last name"] .* ", " .* | |
raw_df[!, "pupil first name"]) | |
prefered_contact = ( | |
ifelse.((raw_df[:, "Parental Contact"] .== 1), | |
raw_df[:, "Parental Contact Name_1"], | |
raw_df[:, "Parental Contact Name_2"]) | |
) | |
out_df[:, "Parental Contact Full Name"] = (raw_df[:, "pupil last name"] .* | |
", " .* prefered_contact) | |
out_df[:, "Parental Contact Email Address"] = ( | |
prefered_contact .* | |
"." .* | |
raw_df[:, "pupil last name"] .* | |
"@" .* | |
raw_df[:, "Preferred Contact Employer"] .* | |
".com") | |
out_df |> CSV.write("output.csv") | |
end | |
parse() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment