Here is a two stage regex solution. Assuming no bullets (•) in your file,

Search: ^([^\t]+)\t([^\t]+)\r(?=\1)
replace: \1\t\2\r•

Search: •[^\t]+
Replace with empty

On Sun, 21 Mar 2021 at 08:47, Christopher Stone <[email protected]>
wrote:

> On 03/20/2021, at 15:48, John Delacour <[email protected]> wrote:
>
> That makes no sense to me.  If the current col1 is identical to col1 of
> the previous line, then the value will not be printed; that is the clear
> logic of the routine.  I cannot reproduce your error.
>
> ------------------------------
>
> Hey Folks,
>
> I'm with JD on this one.  I ran his script on a sample file, and it
> performed as expected.
>
> Samar – I'd want a zipped copy of your test file that's failing to test.
> Also - you said you're working with a *large* file.  How large?  It makes
> a difference in how one approaches the problem.
>
> I like JD's Perl solution for this.  It's neat, clean, fast, and will
> handle big files with ease.
>
> If I *was* to use AppleScript I'd go this route:
>
> -----------------------------------------------------------
> # Auth: Christopher Stone <[email protected]>
> # dCre: 2021/03/21 02:56
> # dMod: 2021/03/21 02:56
> # Appl: BBEdit
> # Task: Massage Text of Columns A and B of a Table.
> # Libs: None
> # Osax: None
> # Tags: @Applescript, @Script, @BBEdit
> -----------------------------------------------------------
>
> *set* colAStr *to* *missing value*
> *set* {oldTIDS, AppleScript's text item delimiters} *to* {AppleScript's text
> item delimiters, tab}
>
> *tell* *application* "BBEdit" *to* ¬
>     *set* paragraphList *to* contents *of* *lines* *of* *front* *document*
> *where* *its* contents *is* *not* ""
>
> *repeat* *with* i *in* paragraphList
>     *if* colAStr = *text item* 1 *of* i *then*
>         *set* contents *of* i *to* tab & *text item* 2 *of* i
>     *else*
>         *set* colAStr *to* *text item* 1 *of* i
>     *end* *if*
> *end* *repeat*
>
> *set* AppleScript's text item delimiters *to* linefeed
> *set* paragraphList *to* paragraphList *as* *text*
> *set* AppleScript's text item delimiters *to* oldTIDS
>
> *tell* *application* "BBEdit" *to* ¬
>     *set* *text* *of* *front* *document* *to* paragraphList
>
> -----------------------------------------------------------
>
> Although it could bog down with very big files.
>
>
> --
> Best Regards,
> Chris
>
> --
> 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/B75B0684-484C-4034-AF69-D0731A9FE590%40gmail.com
> <https://groups.google.com/d/msgid/bbedit/B75B0684-484C-4034-AF69-D0731A9FE590%40gmail.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Kaveh Bazargan PhD
Director
River Valley Technologies <http://rivervalleytechnologies.com/> ● Twitter
<https://twitter.com/rivervalley1000> ● LinkedIn
<https://www.linkedin.com/in/bazargankaveh/> ● ORCID
<https://orcid.org/0000-0002-1414-9098>
*Accelerating the Communication of Research*

-- 
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/CAJ2R9phrfyDckhU2d_Vp6p4XVb4npEcB7Z0DvOUtzMDzBac9Mg%40mail.gmail.com.

Reply via email to