How can I format a column of numbers in an emacs org mode table?

Harry Weston

I have a table in this form, in emacs org-mode. Please, is there a way to format the numbers in columns 3 and 4 to line the decimal points up vertically?

Note, an aside: I sorted the resulting file using bash sort command, and found that the extra | at the start of each line is counted as column 1, so, for instance the column headed OUTPUT is number 4 in this context.

| CALL  | CHAN   |   OUTPUT |    INPUT | QTHR   | LOCATION       | NGR        | REGION   | CTCSS | KEEPER | Internet |
| GB3AH | RB11   |  433.275 |  434.875 | JO02KP | East Dereham   | TF94300990 | EAST ENG |  94.8 | G8PON  |          |
| GB3AS | RV48   |    145.6 |      145 | IO84LS | Wigton,Cumbria | NY33724123 | N.ENG    |    77 | G4KFN  |          |
| GB3AG | RV58   |  145.725 |  145.125 | IO86ON | Forfar         | NO48904170 | SCOT     |  94.8 | GM1CMF | Echolink |
| GB3AY | RV52   |   145.65 |   145.05 | IO75OR | Dalry          | NS26605190 | SCOT     | 103.5 | GM3YKE |          |
| GB3BA | RB01   |  433.025 |  434.625 | IO87SC | Banchory       | NJ72150255 | SCOT     |    67 | GM1XEA |          |
| GB3BD | RB06   |   433.15 |   434.75 | IO92RA | Ampthill       | TL01303860 | SE ENG   |    77 | G8MGP  |          |
| GB3AA | 23cm   |     1297 |     1291 | IO81RO | Alveston,Avon  | ST62608820 | SW ENG   | 118.8 | G4CJZ  |          |
| GB3AI | RV55   | 145.6875 | 145.0875 | IO91QQ | Amersham       | SU97089767 | SW ENG   |    77 | G0RDI  | Echolink |
| GB3AL | RV59   | 145.7375 | 145.1375 | IO91QP | Amersham       | SU95709550 | SW ENG   |    77 | G0RDI  |          |
| GB3AM | R50-13 |    50.84 |    51.34 | IO91QP | Amersham       | SU95709550 | SW ENG   |    77 | G0RDI  |          |
abo-abo

Here are the steps:

  1. This is an optional one, to make things a bit more visual. C-c } turns on the overlays for row and column numbers. Same combination turns the off. Note that these are not the changes in your buffer, they're just tooltips. You might want to do C-c - on the first line, to see the column numbers.
  2. Move cursor to OUTPUT column and insert a new column with C-S-right.
  3. Your cursor should now be in the new column. Type in $4=$3;%0.3f, i.e. copy the third column to the fourth, and format it as a floating point with 3 precision. Press return, and just one cell will fill in. Press C-u C-c * to recalculate all cells. This can also be done with C-c C-c, with cursor on #+TBLFM: line.
  4. You can remove the old column with C-M-left if you want, and delete the table formula below.

UPDATE:

Thanks to input from @phils, here's the alternative way:

  1. Move your cursor to any number in column 3, e.g. 433.275.
  2. Press C-c =, cursor moves to minibuffer.
  3. Enter $0;%0.3f and press return. Here $0 refers to the current column, $3 would also work if it were column 3.
  4. Either press C-u C-c * anywhere in the document, or move the cursor to #+TBLFM: line and press C-c C-c.
  5. Repeat the same process for column 4.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to select a column of a table in emacs org mode

From Dev

Can I fix the width of a column in an org-mode table?

From Dev

Set clock table duration format for emacs org-mode

From Dev

Emacs org-mode: How can i fold everything but the current headline?

From Dev

how can I indent a paragraph of plain text in emacs org-mode?

From Dev

Emacs org mode: how can I filter on tags and todo status simultaneously?

From Dev

emacs org mode: how many lines are in my table?

From Dev

emacs org mode: how many lines are in my table?

From Dev

emacs org mode: how do i refer to the current row number?

From Dev

How do I find org-mode files with completion in Emacs?

From Dev

Emacs org-mode - format source block

From Dev

Emacs org-mode - format source block

From Dev

How do I display line numbers in Emacs (not in the mode line)?

From Dev

How can I convert the Date format for column in sqlite table?

From Dev

How to define a column format for entire org-mode file

From Dev

How can I export an evernote account into Emacs.org?

From Dev

How can I detect whether Emacs is running in batch mode?

From Dev

Emacs/Evil mode - how can I set TAB to cycle buffers?

From Dev

How can I disable emacs delete-selection-mode

From Dev

How can I run Mac OSX graphical Emacs in daemon mode?

From Dev

How can I delete a note written in Emacs howm-mode

From Dev

How to override a keybinding in Emacs org-mode

From Dev

Emacs org-mode: increment equation numbers with latex preview

From Dev

How can I edit text in "column mode"?

From Dev

How can I produce a table with column headers from org-babel shell output?

From Dev

How to export html from emacs org-mode that can be opened in Microsoft Word

From Dev

Inserting an emacs calc vector into an org-mode table spreadsheet

From Dev

How can I emphasize or verbatim quote a comma in org mode?

From Dev

How can I implicitly organize literate code with org-mode?

Related Related

  1. 1

    How to select a column of a table in emacs org mode

  2. 2

    Can I fix the width of a column in an org-mode table?

  3. 3

    Set clock table duration format for emacs org-mode

  4. 4

    Emacs org-mode: How can i fold everything but the current headline?

  5. 5

    how can I indent a paragraph of plain text in emacs org-mode?

  6. 6

    Emacs org mode: how can I filter on tags and todo status simultaneously?

  7. 7

    emacs org mode: how many lines are in my table?

  8. 8

    emacs org mode: how many lines are in my table?

  9. 9

    emacs org mode: how do i refer to the current row number?

  10. 10

    How do I find org-mode files with completion in Emacs?

  11. 11

    Emacs org-mode - format source block

  12. 12

    Emacs org-mode - format source block

  13. 13

    How do I display line numbers in Emacs (not in the mode line)?

  14. 14

    How can I convert the Date format for column in sqlite table?

  15. 15

    How to define a column format for entire org-mode file

  16. 16

    How can I export an evernote account into Emacs.org?

  17. 17

    How can I detect whether Emacs is running in batch mode?

  18. 18

    Emacs/Evil mode - how can I set TAB to cycle buffers?

  19. 19

    How can I disable emacs delete-selection-mode

  20. 20

    How can I run Mac OSX graphical Emacs in daemon mode?

  21. 21

    How can I delete a note written in Emacs howm-mode

  22. 22

    How to override a keybinding in Emacs org-mode

  23. 23

    Emacs org-mode: increment equation numbers with latex preview

  24. 24

    How can I edit text in "column mode"?

  25. 25

    How can I produce a table with column headers from org-babel shell output?

  26. 26

    How to export html from emacs org-mode that can be opened in Microsoft Word

  27. 27

    Inserting an emacs calc vector into an org-mode table spreadsheet

  28. 28

    How can I emphasize or verbatim quote a comma in org mode?

  29. 29

    How can I implicitly organize literate code with org-mode?

HotTag

Archive