title: Removing extra spaces in PowerShell
body: <p>I'd like to use PowerShell to remove superfluous spaces and replace them with a single comma between entries so I can convert the result to a working CSV file for further analysis.</p>
  <p>Here is my code;</p>
  <pre><code>Get-Content –path C:\Users\USERNAME\Desktop\results.txt| ForEach-Object {$_ -replace &quot;\s+&quot;  &quot; &quot; } |  Out-File -filepath C:\Users\USERNAME\Desktop\results.csv
  </code></pre>
  <p>In the text file, the initial results are like this:</p>
  <pre><code> entry     entry     entry    (all separated with 5 spaces)
  </code></pre>
  <p>What I want it to look like is this:</p>
  <p>entry,entry,entry</p>
  <p>So Excel will put them in separate cells.</p>