Solved

Delete line from CSV

Posted on 2009-07-08
2
2,971 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 71

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the adminiā€¦

752 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