On 03/20/2021, at 15:48, John Delacour <[email protected] <mailto:[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] <mailto:[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.
