title: delete the last column from a csv file in powershell
body: <p>I am new to powershell. Currently we are in need of a poweshell script to compare two large (100000 rows and n columns (n > 300, also column headers are Dates corresponding to each wednesday). The value of n keeps on incrementing each week in the file. We need to compare the files (current week and last week), and need to make sure that the only difference between the two files is the last column.</p>
  
  <p>I have gone through some Forums and Blogs and I could do only Little due to my ignorance.</p>
  
  <p>If there is a way to drop the last column from a csv file in powershell, we may be able to make use of the below script below to compare the previous week's file and the current week's file after droping the last column from current week's file.</p>
  
  <p>It would be really helpful if someone can help me here with your hard earned knowledge</p>
  
  <hr>
  
  <pre><code>[System.Collections.ArrayList]$file1Array = Get-Content "C:\Risk Management\ref_previous.csv"|Sort-Object
  [System.Collections.ArrayList]$file2Array = Get-Content "C:\Risk Management\ref_current.csv"|Sort-Object
  $matchingEntries = @()
  
  foreach ($entry in $file1Array) {
      if ($file2Array.Contains($entry)) {
          $matchingEntries += $entry
          } 
      }
  foreach ($entry in $matchingEntries){
      $file1Array.Remove($entry)
      $file2Array.Remove($entry)
      }
  </code></pre>
  
  <hr>
  
  <p>Cheers, 
  Anil</p>