Skip to content

Instantly share code, notes, and snippets.

@CraigChamberlain
Last active December 23, 2020 20:42
Show Gist options
  • Save CraigChamberlain/500496f9424b42a32153e591f6e577b8 to your computer and use it in GitHub Desktop.
Save CraigChamberlain/500496f9424b42a32153e591f6e577b8 to your computer and use it in GitHub Desktop.
Example use of Get-CovidProtectionLevelFromPostCode.ps1
$data = Import-Csv "PupilsByPrimaryAddress.csv"
$uniqueUkPostCode = $data |? {$_.txtCountry -eq "United Kingdom"} |% {$_.txtPostCode} | Sort-Object -Unique |? {$_ -ne ''}
$uniqueUkPostCode |
ForEach-Object -Begin {
$total = $uniqueUkPostCode.count
$i = 0
$dict = @{}
} -Process {
try{
$dict.Add($_, (.\Get-CoronovirusGovData.ps1 $_))
}
catch{
Write-Warning "Problem with: $_"
}
finally{
Write-Progress -Activity "Resolve Covid-19 Resction Tier, MSOA and Local Authority" -Status "Progress: $i of $total" -PercentComplete ($i/$total*100)
$i++
}
} -End {
$dict
}
$localAuthority = @{ Name = "localAuthority"; Expression= { $dict[$_.PostCode].localAuthority }}
$msoa = @{ Name = "msoa"; Expression= { $dict[$_.PostCode].msoa }}
$covidTier = @{ Name = "covidTier"; Expression= { $dict[$_.PostCode].covidTier |% {if($_){$_}else{'-'}} }}
$withAdditionalData = $data | Select -Property *, $localAuthority, $msoa, $covidTier
$withAdditionalData | Export-Csv -NoTypeInformation "ExampleWithCovidLevel.csv"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment