cls if (Test-Path ".\Fusion.csv") { Remove-Item ".\Fusion.csv" } # Charger les fichiers CSV en tant que tableaux associatifs en mémoire $diffusion = @(Import-Csv -Delimiter ";" -Path ".\Diffusion.csv") $auteur = @(Import-Csv -Delimiter ";" -Path ".\Auteur.csv") # Créer un hashtable pour le tableau associatif $auteur, indexé par TITREFILM $auteurIndex = @{} foreach ($row in $auteur) { $auteurIndex[$row.TITREFILM] = $row } # Fusionner les tableaux associatifs en utilisant la colonne "ClipName" pour la jointure $merged = foreach ($row in $diffusion) { if ($auteurIndex.ContainsKey($row.ClipName)) { $matchingRow = $auteurIndex[$row.ClipName] $row | Select-Object *, @{Name='Realisateur';Expression={$matchingRow.Realisateur}}, @{Name='Production';Expression={$matchingRow.Production}}, @{Name='AnneeDeProduction';Expression={$matchingRow.AnneeDeProduction}}, @{Name='Genre';Expression={$matchingRow.Genre}}, @{Name='SousTitre';Expression={$matchingRow.SousTitre}}, @{Name='NumeroEpisode';Expression={$matchingRow.NumeroEpisode}}, @{Name='Saison';Expression={$matchingRow.Saison}}, @{Name='Scenariste';Expression={$matchingRow.Scenariste}}, @{Name='PaysDeProd';Expression={$matchingRow.PaysDeProd}}, @{Name='CodeOeuvre';Expression={$matchingRow.CodeOeuvre}} } } # Exporter le tableau associatif fusionné en tant que fichier CSV $merged | Export-Csv -Delimiter ";" -NoTypeInformation -Path ".\Fusion.csv" -Encoding UTF8