Quantcast
Channel: Active questions tagged powershell-3.0 - Stack Overflow
Viewing all articles
Browse latest Browse all 123

Delete empty rows in multiple csv files by using Powershell [duplicate]

$
0
0

To delete empty rows in multiple CSV files by using Powershell. This is the code I am trying to use for each loop. But it is writing empty files. The resulting file should open in Excel and Notepad++ in proper format.

Get-ChildItem $paramDest -Filter *Test*.csv | ForEach-Object {$content = Get-Content $_.FullName | Where { $_.Replace("","","").trim() -ne "" }Out-File -InputObject $content -FilePath $_.FullName}

enter image description here

I have some other set of files, the code should work for both these kinds of files. I am okay to have 2 separate codes for these 2 separate files.

Here is another file sample format

enter image description here


Viewing all articles
Browse latest Browse all 123

Trending Articles



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