I am trying to automate the process of rename the csv header names. I used the following script, but the script is taking very long time to complete the rename process especially when the file size is very large. How can we optimize the script speed?
$Data=Get-Content -Path "C:/csv/lead.csv"
$Data[0] = "sr_no,dob,email,father_name,mobile,other_mobile_no.,pincode"
$Data | Out-File -FilePath "C:/csv/lead.csv" -Encoding UTF8