title: Import-Csv too Slow
body: <p>I currently have a PowerShell script that will import a CSV file and then filter the 1st column to remove the whole row if the row exceeds a certain time.  However, using <code>Import-Csv</code> takes a very long time.  Is there a different way to achieve the same result without using <code>Import-Csv</code>?</p>
  
  <p>Here is the script at the moment:</p>
  
  <pre><code>$files = Get-ChildItem "C:\Results\*.csv"
  
  foreach ($file in $files) {
      $filename = [IO.Path]::GetFileNameWithoutExtension($file)
      $csv = Import-Csv $file
  
      $dateTime = $csv[0]."Date and Time"
  
      $startTime = $dateTime.Substring($dateTime.get_Length()-8)
  
      $endTime = $startTime
      [int]$hour, [int]$min, [int]$sec = $endTime.Split(':')
  
      $hour = $hour + 1
      $min = 44
      $sec = 59
  
      $csv | ForEach-Object {
          $lineTime = $_."Date and Time"
          $startTime = $lineTime.Substring($lineTime.get_Length()-8)
          $newHour, $newMin, $newSec = $startTime.Split(':')
          if (($newHour -lt $hour -and $newMin -gt $min) -or ($newHour -eq $hour -and $newMin -le $min)) {
              $_ | Export-Csv -Path "C:\PerfResults\NewFiles\$filename-NEW.csv" -Append 
          }
      }
  }
  </code></pre>
  
  <p><strong>EDIT:</strong></p>
  
  <p>As requested by Olaf, below is an example of the data within the CSV file:</p>
  
  <pre>
  Date and Time   Memory Overcommit (1 Minute Avg)    Memory Overcommit (5 Minute Avg)    Memory Overcommit (15 Minute Avg)   Cpu Load (1 Minute Avg) Cpu Load (5 Minute Avg) Load (15 Minute Avg)    Physical Cpu(0)\% Processor Time
  07/24/2018 14:45:03 0   0   0   0.11    0.13    0.11    7.31
  07/24/2018 14:45:06 0   0   0   0.11    0.13    0.12    1.41
  </pre>