Split a text file with tabs based on character position in a line?

49 views
Skip to first unread message

desertrat

unread,
Nov 10, 2022, 1:21:46 PM11/10/22
to BBEdit Talk
There was (back in the Ancient Times..like MacOS 7 or 8) a marvelous little Mac utility called 'Columnbo' which let you break arbitrary text files into tab-delimited by specifying the character position to insert a tab (like  position 65. 90, and 125 in a line of text get tabs inserted so you can parse the text as a tab-delimited file.) It was invaluable in dealing with columnar-looking text data.

Is there any way to do this in BBEdit? Alternatively does anyone know of a modern replacement for Columnbo ?

Peter Kaufman

unread,
Nov 10, 2022, 1:30:32 PM11/10/22
to bbe...@googlegroups.com
Excel can do this - read in fixed length stuff and save it out then as a csv file, but perhaps you're looking at a no cost solution.  I'm sure BBedit can do this, but there are others more capable of answering that.

Peter

On Thu, Nov 10, 2022 at 12:21 PM 'desertrat' via BBEdit Talk <bbe...@googlegroups.com> wrote:
There was (back in the Ancient Times..like MacOS 7 or 8) a marvelous little Mac utility called 'Columnbo' which let you break arbitrary text files into tab-delimited by specifying the character position to insert a tab (like  position 65. 90, and 125 in a line of text get tabs inserted so you can parse the text as a tab-delimited file.) It was invaluable in dealing with columnar-looking text data.

Is there any way to do this in BBEdit? Alternatively does anyone know of a modern replacement for Columnbo ?

--
This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" 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 bbedit+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/6c082a84-9763-49ca-b46f-6321f31e3d41n%40googlegroups.com.


--
-------------------------------------------------------------
Peter Kaufman     PKau...@GMail.Com
United States of America
-------------------------------------------------------------

Adriano Borgobello

unread,
Nov 10, 2022, 1:47:26 PM11/10/22
to bbe...@googlegroups.com
LibreOffice and NeoOffice too ;-)

jj

unread,
Nov 10, 2022, 2:09:10 PM11/10/22
to BBEdit Talk
You could try a 'Replace All' with a regular expression using column width instead of character positions.

Find:

    (.{65})(.{25})(.{35})

Replace:

    \1\t\2\t\3

HTH,

Jean Jourdain

Bruce Johnson

unread,
Nov 10, 2022, 3:25:48 PM11/10/22
to bbe...@googlegroups.com
LOL, I’d forgotten I could do this in a spreadsheet!  Thanks for the suggestions, all.



You received this message because you are subscribed to a topic in the Google Groups "BBEdit Talk" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/bbedit/mpUF87o2jXg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to bbedit+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/CAHrvKtz6b%3D4ocX4wAN595yyso02vxL98o6AgGQQJm86DnLV64g%40mail.gmail.com.

-- 
Bruce Johnson
University of Arizona
College of Pharmacy
Information Technology Group

Institutions do not have opinions, merely customs

Bruce Johnson

unread,
Nov 10, 2022, 3:50:09 PM11/10/22
to bbe...@googlegroups.com
Didn’t work with my example. but this is regexp wizardry beyond my knowledge (or my google-fu is weak today)

This is what I had in the find box:

(.(23)) (.(43)) (.(74)) (.(95))

 Sample data

Name                      Alias           Database                    ProhibitSendQuota    ExternalDirectoryObjectId
----                      -----           --------                    -----------------    -------------------------
Name1                    Alias1          NAMPR190000-xxxx             49.5 GB (53,150,220… objid1
Name2                    Alias2          namPR190000-xxxx             49.5 GB (53,150,220… objid2


No matches were found so nothing got replaced.

This was why I loved Columnbo, just drag a marker to the point you wanted the column to start and bang it replaced any string of spaces to a tab character.  Used it to massage large masses of text into tabular data.

--
This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
---
You received this message because you are subscribed to a topic in the Google Groups "BBEdit Talk" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/bbedit/mpUF87o2jXg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to bbedit+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/c4b0ab86-36ab-48f8-8dbd-e2a94c9b89d6n%40googlegroups.com.

Tom Robinson

unread,
Nov 10, 2022, 4:10:40 PM11/10/22
to BBEdit Talk
Not sure what your intent was with that regular expression?

This inserts tabs between columns, based on their width.  You’ll need a second pass to remove trailing spaces:

Find:  ^(.{25})(.{16})(.{29})(.{21})(.+)$

^ Anchors to start of line
( Start a capture buffer ( \1 )
. Any single character
{25} That single character 25 times
) End capture buffer


Replace:  \1\t\2\t\3\t\4\t\5


Cheers

Bruce Johnson

unread,
Nov 10, 2022, 4:30:25 PM11/10/22
to bbe...@googlegroups.com
I merely copied what I saw in Jean Jourdain’s post and didn’t recognize the brackets as such. Time for bigger text in my email or new glasses . Thank you for the explanation!

--
This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
---
You received this message because you are subscribed to a topic in the Google Groups "BBEdit Talk" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/bbedit/mpUF87o2jXg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to bbedit+un...@googlegroups.com.

Adriano Borgobello

unread,
Nov 10, 2022, 4:46:21 PM11/10/22
to bbe...@googlegroups.com
But if you want to do it with BBEdit, you could select the first text column using option key, copy & paste it to a new document and replace “\n" with "\t\n". After that, you should select and copy the next column, go to end of first row, and option-paste the text column. After that, you'll repeat replacement and so on. Easier to do than explain.

jj

unread,
Nov 11, 2022, 5:10:27 AM11/11/22
to BBEdit Talk
Another option (pun intended) is to select a multiline vertical insertion point selection by <option-dragging> the cursor vertically (that is creating a vertical selection while holding the <OPTION> key)
                                             |
      ---------------------------------------+
    /
   v
abc|def
abc|def
abc|def

And then typing a <TAB>.
Reply all
Reply to author
Forward
0 new messages