I have this CSV file.
Actual CSV data is limited to ";" , like this:
[2017-04-27 15:45:04]
You can see that there is a "Terminaison" column that contains information about success or failure. My goal is to display all the columns of a file in a gridview.
I do:
import-csv "C:\x\Journal\Capsule\CapsulePoste.csv" -Delimiter ";"
and get the desired result with all the columns containing the correct data:
Now here is my question: when I want to display all this in a GridView, is the "terminaison" column empty? What for? All other columns are displayed correctly ... :
import-csv "C:\x\Journal\Capsule\CapsulePoste.csv" -Delimiter ";" | out-gridview
I found that the white space at the end of the header (the first line of the CSV file) causes this ...
Date;Trousse;Version;Demandeur;Action;Paramรจtres;Terminaison
(there is a space immediately after Terminaison)
If I edit CSV in notepad and delete this empty space, bingo, it works. However, this does not solve my problem, since I do not want to edit the file in advance. What is this weird restriction and is there a workaround?
EDIT:
The answers below are excellent. I ended up using another option that I think should be added to the features:
$content = Get-Content C:\x\Journal\Capsule\CapsulePoste.csv $content | Foreach {$_.TrimEnd()} | Set-Content C:\x\Journal\Capsule\CapsulePoste.csv import-csv "C:\x\Journal\Capsule\CapsulePoste.csv" -Delimiter ";"| sort-object Date -descending
powershell import-csv
Rakha
source share