pf-csv.ps1
function Get-CSV_Matrix ($path, $colPropName = 'ColumnHeader', $rowPropName = 'RowHeader', $dataPropName= 'Cell') { function unquote { process { $_ | Update-Prefix -prefix '"' | Update-Suffix -Suffix '"' } } $path = get-path $path $rows = Get-Content -Path $path $colheaders = $rows[0] -split ',' | unquote $rows = $rows[1..($rows.Count)] foreach ($row in $rows) { $data = $row | ForEach-Object { $_ -split ',' } $rowHeader = $data[0] | unquote $colPos = 0; foreach ($cell in $data[1..($data.Count)] ) { $colPos = $colPos + 1 [PsCustomObject]@{ $colPropName = $colheaders[$colPos] $rowPropName = $rowHeader $dataPropName = $cell | unquote } } } } function Get-CSV_Matrix:::Example { Get-CSV_Matrix -path C:\temp\HRTestAccountsXX.csv } |