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

CVS + Prefix + unwanted space

$
0
0

Hello All,

I am trying to create a third column in a CSV file called Groups with content data from the dept column appended with the prefix of “test”. With the below code I am getting a space between test and the dept name. Any ideas why I am getting the space?

 

Examples

original CSV file:

LoginID,Dept

user1,Financial

 

wanted CSV output:

LoginID,Dept,Groups

user1,Financial,testFinancial

 

what I am getting:

LoginID,Dept,Groups

user1,Financial,test Financial

 

 

Import-Csv dept.csv |

Select-Object *,@{Name="Groups";Expression={"test",$_.Dept}} |

Export-Csv dept_1.csv

 

Thank you

Normal 0 false false false EN-US X-NONE X-NONE

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles