Assuming your data is in a file called your.csv and the contents are as follows:
ColA,ColB,ColC
somethingA,somethingB,SomethingC
somethingA,somethingB,SomethingC
somethingA,somethingB,SomethingC
somethingA,somethingB,SomethingC
somethingA,somethingB,SomethingC
somethingA,somethingB,SomethingC
An efficient way to do this is following a solution posted at Add Column to CSV Windows PowerShell. Here are the details following that method where you want to replace the first column and keep the remaining columns in order:
Import-Csv your.csv |
Select-Object -Property @{n="ColA";e={get-date -f MMddyyyy}},* -ExcludeProperty ColA |
Export-Csv new.csv -NoTypeInformation
A less efficient alternative processes each row and makes the appropriate change. This will update the original $file
variable with the new data, but will leave the original file unchanged. new.csv is the output file with all of the updates.
$file = Import-Csv your.csv
Foreach ($row in $file) {
$row.ColA = get-date -f MMddyyyy
}
$file | Export-Csv new.csv -NotypeInformation
Now, the contents of new.csv are as follows:
"ColA","ColB","ColC"
"04042019","somethingB","SomethingC"
"04042019","somethingB","SomethingC"
"04042019","somethingB","SomethingC"
"04042019","somethingB","SomethingC"
"04042019","somethingB","SomethingC"
"04042019","somethingB","SomethingC"