I am currently in need of a solution for one of our automation scripts. As part of the process it grabs the file from a source and it has to remove last row in the .csv and save it again as csv file(not sure why this has to be done, as file already comes as .csv, but without it - it bugs out). The problem is that I can't seem to figure out how to remove the last row. I came up with few solutions but most only work on .txt file or objects. What I have now is this:
Import-Csv $file | where {$_.'Search Status' -ne "Blank line"} | Export-Csv "\file.csv" -notypeinfo
It does delete the last line that has ' Blank Line' written in it, but it seems to just remove the text and when my other script parses the file it fails to do so properly. So to sum up - I need a script that would take this file, remove last row completely and save it again as .csv as 'export-csv' doesn't seem to do the job.