public/Get-FootballDataFixtureReverseFixture.ps1

function Get-FootballDataFixtureReverseFixture {
    <#
        .SYNOPSIS
            Returns the reverse fixture.
 
        .DESCRIPTION
 
            Returns the reverse fixture. chelsea vs Aresenal returns Aresenal vs
    #>

    [CmdletBinding()]
    param(

        [Parameter(Mandatory=$true)]
        [ValidateNotNullOrEmpty()]
        [string]$Competition,

        [Parameter(Mandatory=$true)]
        [ValidateNotNullOrEmpty()]
        [string]$Date,

        [Parameter(Mandatory=$true)]
        [ValidateNotNullOrEmpty()]
        [string]$Path

    )
    process{

        $ErrorActionPreference = 'Stop'

        try {
            # C:\Users\colin\Desktop\sportsmonk
            $FotballHistory = Get-FootballDataFixtureHistory -Competition $Competition -Path $Path
            $FotballHistory | Export-Csv -Path "$Path\football-data-name-change\$Competition.csv"
            $FixturesToPlay = Import-Csv -Path "$Path\sportsmonk-predictions\$Competition\$Date\$Competition-240-$Date.csv"
            $ReverseFixtures =@()

            foreach ($FixtureToPlay in $FixturesToPlay) {

                $Teams = $($FixtureToPlay.FixtureName).Split(' vs ')
                $HomeTeam = $Teams[0]
                $AwayTeam = $Teams[1]
                $ReverseFixture = "$AwayTeam vs $HomeTeam"
                $ReverseFixtures += $FotballHistory | Where-Object {$_.ReverseFixtureName -eq $ReverseFixture}

            }

            $FixturesToPlay | Select-Object -Property FixtureName,StartingAt | Format-Table
            $FTime = $ReverseFixtures | Select-Object -Property ReverseFixtureName,HomeTeam,AwayTeam,Date,Time,HomeGoals,AwayGoals,Result
            $HTime = $ReverseFixtures | Select-Object -Property ReverseFixtureName,HomeTeam,AwayTeam,Date,Time,HTimeHomeGoals,HTimeAwayGoals,HTimeResult
            $Cards = $ReverseFixtures | Select-Object -Property ReverseFixtureName,HomeTeam,AwayTeam,Date,Time,HomeYellowCards,HomeRedCards,AwayYellowCards,AwayRedCards

            $FTime | Export-Csv -Path "$Path\football-data-name-change\$Competition-historical-ftime.csv" -Force
            $HTime | Export-Csv -Path "$Path\football-data-name-change\$Competition-historical-htime.csv" -Force
            $Cards | Export-Csv -Path "$Path\football-data-name-change\$Competition-historical-cards.csv" -Force

            $FixturesToPlay | Select-Object -Property FixtureName,StartingAt  | Format-Table
            $ReverseFixtures | Format-List

        
        }
        catch {

            $_.Exception

        }

    } # process

} # function