Delete alternate rows

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
harrycornelius
Posts: 7
Joined: Tue Jan 16, 2007 12:06 pm

Delete alternate rows

Post by harrycornelius »

Hi

Is there a way to delete alternate rows in Textpad?

I can do it in Excel, but I really need to do it in Textpad as we're talking about very large files here, and Textpad is by far the best editor for this kind of work.

Thanks,
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

If the first line to be deleted is the second line of the file:
Find what: (.*)\n.*\n
Replace with: \1\n

[X] Regular expression
If the first line to be deleted is the first line of the file:
Find what: .*\n(.*)\n
Replace with: \1\n

[X] Regular expression
These assume you are using Posix regular expression syntax:
Configure | Preferences | Editor

[X] Use POSIX regular expression syntax
Edit: I had those the wrong way around. Now corrected.
Last edited by ben_josephs on Tue Jan 16, 2007 3:20 pm, edited 1 time in total.
harrycornelius
Posts: 7
Joined: Tue Jan 16, 2007 12:06 pm

Post by harrycornelius »

That was quick, Ben, fantastic!

Thanks,
harrycornelius
Posts: 7
Joined: Tue Jan 16, 2007 12:06 pm

Delete rows

Post by harrycornelius »

Hi

I have a need to take a list of items, and delete the 2nd, 3rd, 4th, 6th,7th,8th rows etc. for a VERY large file.

FYI it's to strip down a 50m height grid file to a 200m grid file.

Can anyone assist? I have tried a macro, but it just deletes everything.

Any help appreciated.
BenjaminB
Posts: 10
Joined: Tue Sep 12, 2006 3:09 pm

Post by BenjaminB »

We need more information on the format of your file. And I don't quite understand what you are trying to do, anyway.
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

The obvious extension of my earlier suggestion is
Find what: (.*)\n.*\n.*\n.*\n(.*)\n.*\n.*\n.*\n
Replace with: \1\n\2\n

[X] Regular expression
Presumably you've tried that and found it doesn't do what you want. Please explain in exactly what way it doesn't work.
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Or even
Find what: (.*)\n.*\n.*\n.*\n
Replace with: \1\n

[X] Regular expression
Post Reply