Variable fixed width problem

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, MudGuard

Post Reply
telephone
Posts: 15
Joined: Thu Jun 28, 2007 2:33 pm

Variable fixed width problem

Post by telephone »

I have a 250 MB account ledger that is fixed width throughout, the problem is the width changes from page to page so I can't set a standard width when importing into Excel. So, the quick of it is, is there an easy way to remove all these spaces between the columns and replace them with a simple delimiter? For each row, I just need all the whitespace to be replaced between each letter or digit, but again, it's variable throughout the whole file, i.e. 20 spaces may separate ColumnA from ColumnB the first 50 pages and then it could be 30 spaces after that, and so on.


ColumnA ColumnB ColumnC

becomes

ColumnA,ColumnB,ColumnC

However, a space may also appear in some of the row entries, i.e. "Profit Sharing", but never the columns, so maybe there is a way to search for a single whitespace surrounded by non-whitespace and replace that with something else, like an underscore.

Maybe there isn't any way of doing this actually, but incase there is, just thought I'd ask.

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

Post by ben_josephs »

You haven't explained how to distinguish between spaces within the fields and spaces between the fields.

If the fields are separated by at least two spaces, and if the separator you want is a comma, you can use this:
Find what: _{2,} [Replace the underscore with a space]
Replace with: ,

[X] Regular expression

Replace All
This assumes you are using Posix regular expression syntax:
Configure | Preferences | Editor

[X] Use POSIX regular expression syntax
telephone
Posts: 15
Joined: Thu Jun 28, 2007 2:33 pm

Post by telephone »

Thanks Ben, it worked out great.
Post Reply