Unable to add an extra column to an existing CSV file

后端 未结 2 629
Happy的楠姐
Happy的楠姐 2021-01-16 05:14

I have a .csv file which contains data as below:

Name ID
ABC 1234
CDE 3456

I am trying to insert a column called \"Date\" as the first col

2条回答
  •  醉酒成梦
    2021-01-16 05:52

    You can make use of calculated properties like this -

    Import-Csv -path C:\filename.csv |
    Select-Object *,@{Name='Date';Expression={'2018-03-28'}} | 
    Select-Object Date, Name, ID |
    Export-Csv -path C:\Outfile.csv -NoTypeInformation
    

提交回复
热议问题