Solved

Delete line from CSV

Posted on 2009-07-08
2
2,876 Views
Last Modified: 2012-06-27
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
0
Comment
Question by:ptea
2 Comments
 
LVL 70

Accepted Solution

by:
Chris Dent earned 125 total points
ID: 24802331

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
 

Author Closing Comment

by:ptea
ID: 31601046
perfect, many thanks!
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
A procedure for exporting installed hotfix details of remote computers using powershell
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question