EDIT: I missed the ... hand-aligned by TABs...
part, and since I never use TAB characters in my files (except in Makefiles where they are significant), I misinterpreted the input. Nevertheless, the answer below might still be useful.
The function org-table-convert-region
can be used to convert textual tabular material into an org table. Ideally, the textual material would have unambiguous field boundaries (e.g. commas or tabs in the case of CSV/TSV files), but the function can deal with somewhat regular ambiguous situations like the one you have: you have spaces separating the fields but you also have a single space between first and last name in the Names
column; a quick look shows that if you can specify a separator of two or more spaces, that should be enough.
Fortunately the function can take a separator
argument and as the doc string (C-h f org-table-convert-region
) shows, you can specify a regular expression for it: " +"
(there are two spaces in there) will match two or more spaces. However, you will have to evaluate the function non-interactively to be able to specify the separator.
Start by marking the region (C-SPC
on one end and then move point
to the other end) and then say:
M-: (org-table-convert-region (region-beginning) (region-end) " +")
You will also have to add the hline that separates the header line from the body of the table by hand. But that's easily done:
open a line and type |-
followed by TAB
to realign the table.
EDIT: BTW, you could deal with multiple TABs the same way as above. The separator regexp would have to be changed to "\t+"
(i.e. one or more TABs) but that's all.
However, reformatting the original file to provide unambiguous field boundaries (e.g. a single TAB or a single comma) would make it a two-step operation as described by @FranBurstall's answer. Preprocessing the input to make it convenient for future transformations is a technique that's worth keeping in the back of your mind. And it does not have to be done in Emacs: a sed
script can do it easily in your case, converting multiple TABs to a single one: sed -E 's/\t+/\t/g'
(with GNU sed
) should do it.
table.el
tables? For the alignment, see my answer.C-c backquote
, the org-mode editor inserts those row separators. Puzzling...C-c <backquote>
is bound toorg-table-edit-field
. Are you sure you are not talking abouttable.el
tables?