Import-CSV Header not first line

Hi,
I am having a CSV having 2 lines of description and whatever and 3 line is my header.
How can I tell the Import-CSV command to use the 3 line instead of line 1 for header?

Thank you for help

mk.maddin

Technically, that’s not a valid CSV file. However, you should be able to get around this by using Get-Content, Select-Object with the -Skip parameter, and ConvertFrom-Csv instead of Import-Csv:

$csvPath = 'C:\Temp\Whatever.csv'
$csvData = Get-Content -Path $csvPath | Select-Object -Skip 2 | ConvertFrom-Csv

Dave’s solutions almost worked. But I ran into problems that line breaks in quotations are not handled correctly. It took me quite some time to realize the problem and find an easy solution to fix it: concatenate lines (using Out-String) before sending them to ConvertFrom-Csv.

$csvPath = 'C:\Temp\Whatever.csv'
$csvData = Get-Content -Path $csvPath | Select-Object -Skip 2 | Out-String | ConvertFrom-Csv

Using a temporary file also works.