Page 1 of 1

sorting a tab delimitted file

Posted: Thu Feb 21, 2002 12:23 am
by Elaine Shuman
I want to sort a file that has 3 columns of uneven length and delimitted by tabs. How can I sort on the second "column".

I've gone back and forth between Textpad and Excel, using Excel to sort, but Excel adds double quotes when I open the file again in Textpad, which just makes more work.

thanks
Elaine

Re: sorting a tab delimitted file

Posted: Fri Feb 22, 2002 4:08 pm
by Mark Schnitzius
There's no explicit way to do a sort on the second tab-delimited column in Textpad. But you can set up a macro to do what you want, I think:

1. Start your macro recording.

2. Swap the second column with the first by doing a Replace (with Regular Expression checked) of

^\([^\t]*\)\t\([^\t]*\)

with

\2\t\1

Do a Replace All.

3. Do a normal Sort.

4. Repeat step 2 to swap the columns back

5. Stop your Macro recording.

You should then have a macro that does what you want. Hope this helps.