Since your address parts have varying lengths, a simple grep replace 
pattern using fixed tabs isn't always going to produce the desired result.

A solution is to use a perl script text filter. Using Brian Forte's grep 
seach expression in a perl script for a text filter, I came up with this:

#!/usr/bin/perl -w

# to ensure while each is supported
use v5.12;
use strict;

# change the number to adust the size of the psuedo tabs between columns
my $spacesPerTab = 4;
my @dateParts = ();
my @addrParts = ();
my @costParts = ();
my $maxAddrLen =0;
# for each input line, break it up into parts, and find maximum length of 
all the address parts
while (<>) {
    chomp;
    $_ =~ 
m!^([0-9]{2}/[0-9]{2}/[0-9]{2})\s{1,}(.*[A-Z]{2,})\s{1,}([0-9]{1,}\.[0-9]{2})!;
    push @dateParts, $1;
    push @addrParts, $2;
    push @costParts, $3;
    if (length($2) > $maxAddrLen) {
        $maxAddrLen = length($2);
    }
}
# for every line, pad the address part to maximum read length and then 
print out space separated parts 
while (my ($i, $addr) = each @addrParts) {
    if (length($addr) < $maxAddrLen) {
        $addrParts[$i] = $addr.(" " x ($maxAddrLen - length($addr)))
    }

    print $dateParts[$i], " " x $spacesPerTab, $addrParts[$i], " " x 
$spacesPerTab, $costParts[$i], "\n";
}

I saved it as "Columnize_date_address_price.pl" in BBEdit's Text Filters 
support folder. (Although I didn't do so, you can assign a keyboad shortcut 
to it in the Text Filters pallet.)

To use it, select the lines of text you want to tidy up into neat columns. 
Then on the Text Filters pallet, select "Columnize_date_address_price" and 
click on the "Run" tab button. (You might want to test on copy examples to 
ensure it is working as desired for any more elaborate cases you may have.) 

I would have included what the filter result would be for your example data 
but the forum isn't using mono sizing for space characters so the price 
column isn't showing a good alignment in a pasted in result.

I used spaces to regularize the column separation since the width of tabs 
are pretty variable. If you want the result entabbed, BBEdit has a "Convert 
Spaces to Tabs…" menu item for that.

Lastly, although I haven't done so, you could modify the perl script to 
tidy up the price column so the decimal point aligns up for all the prices.

On Wednesday, February 14, 2024 at 3:05:25 PM UTC-8 Kim Mosley wrote:

> I want to add tabs (or something else that might be better) so that I can 
> have three columns… date, vendor with city, and price.
>
> Can someone help?
>
> Thanks!
>
> 01/03/23 CENTRAL MARKET 61 AUSTIN, TX 45.00
> 01/04/23 H-E-B 425 AUSTIN, TX 74.62
> 01/09/23 CENTRAL MARKET 61 AUSTIN, TX 43.70
> 01/10/23 WHOLEFDS LMR 10145 AUSTIN, TX 62.25
> 01/13/23 SQ *ASAHI IMPORTS Austin, TX 24.46
> 01/14/23 CENTRAL MARKET 61 AUSTIN, TX 29.22
> 01/17/23 CENTRAL MARKET 61 AUSTIN, TX 28.25
> 01/18/23 CENTRAL MARKET 61 AUSTIN, TX 19.34
> 01/21/23 CENTRAL MARKET 61 AUSTIN, TX 1.83
> 01/21/23 CENTRAL MARKET 61 AUSTIN, TX 18.34
> 01/23/23 CENTRAL MARKET 61 AUSTIN, TX 19.85
>

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "[email protected]" rather than 
posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/914539dd-1865-446d-8f17-c0c2f6f45a17n%40googlegroups.com.

Reply via email to