Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Merging two columns in a CSV

$
0
0

Merging two columns in a CSV to make a third

$objs=@();

$output=Import-csv-Path"U:\Abook1.csv"|ForEach {

$Object=New-ObjectPSObject-Property @{           

        CN  =[String]::Concat($_.Surname,$_.Firstname)

        Firstname=$_.firstname

        Surname=$_.Surname

        PersonalRef=$_.PersonalRef          

    }  

    $objs+=$Object;

}

$objs

$objs|Export-CSvU:\LeaversFeb2015.csv

 

Outputs this

CN                          Firstname            PersonalRef       Surname

HallJonathan      Jonathan             1234156                Hall

I need CN to be Hall, Jonathan so how to I add the separator to

CN  =[String]::Concat($_.Surname,$_.Firstname)


Viewing all articles
Browse latest Browse all 6937

Trending Articles