Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Remove last line from a CSV file

$
0
0

I have a csv file that has a carriage return at the end of the file.  The program that I need to feed the CSV file errors out if there is that additional space.  I can edit it out manually but would like to remove it with powershell.  How can I achieve this?

I have tried bote of the commands below but they do not seem to work.  I have also tried the trim command none then have any affect on a carriage return.

(Get-Content $addQuota |?{ $_.Replace(",","") -ne "" })| Out-File $addQuota
(Get-Content $addQuota |?{ $_.Replace(",","") -ne "" })| Set-Content $addQuota

Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>