'Export a CSV file starting from a specific row
I have an SQL Query which I'm exporting to a .CSV using PowerShell, but I would like to point to a specific row to start writing the data. For example, I want to start at row number 4, and in this case lines 1, 2, 3 would be empty.
Part of my code:
$SqlAdapter.Fill($DataSet) | export-csv -Delimiter $delimiter -Path "E:\Excel\Folder\MyFile.csv" -NoTypeInformation
Solution 1:[1]
Easiest way would be using Select-Object with the -Skip parameter:
$SqlAdapter.Fill($DataSet) | Select-Object -Skip 3 |
Export-Csv -Delimiter $delimiter -Path "E:\Excel\Folder\MyFile.csv" -NoTypeInformation
-Skip would be skipping the first 3 objects in this case.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Santiago Squarzon |
