Powershell Import/Export-csv group & join cells
I have a csv file which I need to group and join various cells together and have them then separated by a semi-colon in the csv layout is as such
I have managed to join the cells 'price' & 'functionnumber' together and separate them with a ';' but for 'datedespatched' and 'username' which just need to display the 1 name or date the cells return with 'System.Object[]' displayed in the condensed cell, the 'referencenumber' cell appears to condense down fine. This is my current code and the output I receive from it
Import-Csv 'C:\temp\test.csv' | Group-Object ReferenceNumber |ForEach-Object {
[PsCustomObject]@{
ReferenceNumber = $_.Name
userName = $_.Group.userName
DateDespatched = $_.Group.DateDespatched
functionnumber = $_.Group.functionnumber -join '; '
Price = $_.Group.Price -join '; '
}
} | Export-Csv 'C:\temp\test-export.csv' -NoTypeInformation
Thank you in advance
from Recent Questions - Stack Overflow https://ift.tt/2HNLPho
https://ift.tt/eA8V8J
Comments
Post a Comment