0

Exporting or deleting of the specific rows. My big text file (structure: date, url, title):

2018-11-23 15:03:06;$https://super.cz;$Super.cz
2018-11-26 14:09:06;$https://novinky.cz;$Novinky
2018-11-26 15:13:06;$https://denik.cz;$
2018-11-27 08:06:13;$https://www.google.com;$Google.com
etc.

Desired structure of text file (deleting of the third and other row):

2018-11-23 15:03:06;$https://super.cz;$Super.cz
2018-11-26 14:09:06;$https://novinky.cz;$Novinky
2018-11-27 08:06:13;$https://www.google.com;$Google.com
etc.

1 Answer 1

1

Just read the file and drop lines that end with ;$, then write the modified content back to the file.

$file = 'C:\path\to\your.csv'
(Get-Content $file) | Where-Object {
    $_ -notlike '*;$'
} | Set-Content $file

Note that the parentheses around the Get-Content call are required here, because you need to finish reading the entire file first before writing back to the same file (otherwise you'd end up with an empty file).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.