powershellautomation

Skip the first line import-csv in Powershell


Is it possible to skip the first line on a csv file when i do import-csv? Like in this photo. My logical header are the 'nom du client, client ipv4,etc.... But the header that powershell show me is the QM4338... enter image description here

How is it possible to take the second line for my true header ?


Solution

  • You can read the file contents from disk with Get-Content, then discard the first line and pipe the remaining lines to ConvertFrom-Csv:

    $csv = Get-Content $path |Select-Object -Skip 1 |ConvertFrom-Csv -Delimiter ';'