PowerShell: How to Use Export-Csv with No Headers


Often you may want to use the Export-Csv cmdlet in PowerShell to export data to a CSV file with no headers.

Unfortunately, there is no built-in statement to do so, but an easy workaround is to use convertto-csv with select-object -skip as follows:

$data | convertto-csv | select-object -skip 2 | out-file 'data_no_header.csv'

This particular example will export the data saved in the variable named $data to a CSV file without the first row included, i.e. without a header.

The following example shows how to use this syntax in practice.

Example: How to Use export-csv with No Headers in PowerShell

Suppose we have a CSV file saved in the following location:

  • c:\users\bobbi\basketball_data.csv

Here is what this file looks like when we open it in Notepad:

Suppose that we would like to import this file into PowerShell, then simply export it with no header row.

We can use the following syntax to do so:

$data | convertto-csv | select-object -skip 2 | out-file 'data_no_header.csv'

The following screenshot shows how to use this syntax in practice:

PowerShell export-csv no headers

We can then navigate to this CSV file that we exported named basketball_no_header.csv and view it:

Notice that this file contains all of the same data as basketball_data.csv but without the header row.

If you’d like, you can also store this CSV file as a variable and view the contents of it within PowerShell:

Notice that the file contains all of the same data as basketball_data.csv but without the header row.

Related Tutorials

The following tutorials explain how to perform other common tasks in PowerShell:

PowerShell: How to List Files in Directory by Date
PowerShell: How to Get Most Recently Modified File in Directory
PowerShell: How to List All Files in Directory to Text File
PowerShell: How to Delete All Files with Specific Extension

Leave a Reply