Improve company productivity with a Business Account.Sign Up

x
?
Solved

Delete line from CSV

Posted on 2009-07-08
2
Medium Priority
?
3,356 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 71

Accepted Solution

by:
Chris Dent earned 500 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

Worried about phishing attacks?

90% of attacks start with a phish. It’s critical that IT admins and MSSPs have the right security in place to protect their end users from these phishing attacks. Check out our latest feature brief for tips and tricks to keep your employees off a hackers line!

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
After a recent Outlook migration from a 2007 to 2010 environment, some issues with Distribution List owners were realized. In this article, I explain how that was rectified.
Loops Section Overview
Screencast - Getting to Know the Pipeline

584 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