title: Looking for help optimizing a Powershell script to parse through a CSV line by line
body: <p>I have a large csv file with 41000 rows of data.  Within this I have to go through and inspect each row for a particular string PRCXX and if the row contains that in column 6 then I take the value of column 10 and replace the value in column 9 with it.  </p>
  
  <p>I have code that works however it takes a very long time to parse through line by line.  I am looking for some help to try and optimize it.  I have tried switching to a ForEach loop however I am not sure how exactly to get it to work with what I am trying to accomplish and haven't been able to find any examples to work from.</p>
  
  <p>Here is the code that I have that currently is working just takes along time to complete.</p>
  
  <pre class="lang-bsh prettyprint-override"><code>Import-Csv $TransFile -Header 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19 | ForEach-Object {
      if ($_.6 -match "PRCXX") {
      $_.9 = $_.10
      } 
  $_ | Export-Csv test2.csv -NoTypeInformation -Append -Delimiter ","
  }
  </code></pre>
  
  <p>Thanks for any help that you can provide.</p>