title: Trim csv cell string with Powershell
body: <p>I am having trouble using the .Trim() function on a column within a csv file. This csv file only contains one column in the whole table so it should be pretty straight forward (he says).</p>
  
  <p>The data within my csv, Exhibit A (<strong>NOTE: This is all in one field/column, not separate columns</strong>):</p>
  
  <pre><code>Name
  C:\Users\kgroome\Documents\NOC\Documentation\Chrome, .pdf
  C:\Users\kgroome\Documents\NOC\Documentation\CLI, .docx
  C:\Users\kgroome\Documents\NOC\Documentation\DNS, .pdf
  C:\Users\kgroome\Documents\NOC\Documentation\Encryption, .pdf
  C:\Users\kgroome\Documents\NOC\Documentation\Excel, .xlsx
  </code></pre>
  
  <p>Ideally I need to trim everything from right to left after the final 5 characters within the string OR split after the <code>,</code> as this would be much more ideal</p>
  
  <p>What I currently have in regards to syntax for splitting after the <code>,</code> is the following:</p>
  
  <pre><code>$data = Import-Csv "C:\Support\Test05.csv"
  
  foreach($line in $data){
  
      $line.split(',')[5].Trim(); |
  
      Export-Csv -Path "C:\Support\Test06.csv"
  
   }
  </code></pre>
  
  <p>Albeit this isn't my best, I have had previous syntax for both methods however I have scrapped it because it was near useless.</p>
  
  <p>Your help would be extremely appreciated so I can know why I am going wrong!</p>