I have a CSV file which looks something like this:
Column1,Column2,Column3
John,Smith,\"AA, AH, CA, NI, PB\"
Regin
Use Import-Csv
to read the input file, then split the third column and create new output lines for each resulting element:
Import-Csv 'C:\path\to\input.csv' | ForEach-Object {
foreach ($value in ($_.Column3 -split ', ')) {
$_ | Select-Object -Exclude Column3 -Property *,@{n='Column3';e={$value}}
}
} | Export-Csv 'C:\path\to\output.csv' -NoType
The Select-Object
construct replaces the existing property Column3
with a new property Column3
that contains only a single value.