Delete line from CSV

Hi there,

I want to import a csv file an delete the first two lines and each line which starts with [,].

How to do that?

Thanks
pteaAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Chris DentConnect With a Mentor PowerShell DeveloperCommented:

Like this?

Chris
$File = Get-Content "FileName.csv"
# Drop the first two lines
$File = $File[2..$($File.Count - 1)]
# Drop any line starting with ","
$File = $File | ?{ $_ -NotLike ",*" }
# Dump it to a new file
$File > "NewFileName.csv"

Open in new window

0
 
pteaAuthor Commented:
perfect, many thanks!
0
All Courses

From novice to tech pro — start learning today.