Solved

Delete line from CSV

Posted on 2009-07-08
2
3,078 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

Ready to trade in that old firewall?

Whether you need to trade-up to a shiny new Firebox or just ready to upgrade from whatever appliance you're using now, WatchGuard has the right appliance for you! Find your perfect Firebox today with appliance sizing tool!

Question has a verified solution.

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

Synchronize a new Active Directory domain with an existing Office 365 tenant
A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

635 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