سؤال

I currently have the following csv

These, Are, Several, Columns
-----, ---, -------, -------
"And", "here", "is", "data"
"And", "some", "more", "data"

While I wish I could simply change the process that creates the csv to remove the line of dashes that isn't possible.

The line of dashes is always the 2nd line, can I use powershell to remove the 2nd line of data?

Bonus question, I'm looking to add at the bottom a blank line, followed by a paragraph of text. I'm guessing I would be able to use the add-content cmdlet, but I'm not entirely sure how.

هل كانت مفيدة؟

المحلول

This command should work:

gc file.txt | ? { $_ -notlike '*----*' } | sc file2.txt

It essentially performs the following tasks:

  1. Retrieves the content of file.txt
  2. Filters (using Where-Object) content for lines not like ----
  3. Writes the remaining content to file2.txt
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top