title: Using duplicate headers in Powershell .csv file
body: <p>I have a .csv file and I want to import it into powershell then iterate through the file changing certain values. I then want the output to append to the original .csv file, so that the values have been updated.</p>
  
  <p>My issue is that the .csv file has headers which aren't unique, and can't be changed as then it won't work in another program. Originally I defined my own headers in the powershell to get around this but then the output file has these new headers when it needs to have the old ones.</p>
  
  <p>I have also tried <code>ConvertFrom-Csv</code> which means I can no longer access the columns I need to, so lots of runtime errors.</p>
  
  <p>What would be ideal is to be able to use the defined column headers and then convert back to the original column headers. My current code is below:</p>
  
  <pre><code>$csvfile = Import-Csv C:\test.csv| Where-Object {$_.'3' -eq $classID} | ConvertFrom-Csv
  foreach($record in $csvfile){
  *do something*}
  $csvfile | Export-Csv -path C:\test.csv -NoTypeInformation -Append
  </code></pre>
  
  <p>I've searched the web now for some hours and tried everything I've come across, to no avail.
  Thanks in advance.</p>