Skip first line with import-csv

Friday, October 20th, 2017

I have a data file which generates with a header line. I have check script which uses the file and I wanted to skip it but I am using a foreach loop and did not want to add an if/then.

The problem line:

Import-Csv $file -header("fullname","email", "notification","version") foreach {

I remembered the select -first option and I wondered if there was a skip option?

I made a quick change and added a pipe with select -skip 1

Import-Csv $file -header("fullname","email", "notification","version") | select -skip 1 | foreach {

Tested the script and sure enough the first line was skipped.

 

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: