Function: org-table-transpose-table-at-point

org-table-transpose-table-at-point is an interactive and byte-compiled function defined in org-table.el.gz.

Signature

(org-table-transpose-table-at-point)

Documentation

Transpose Org table at point and eliminate hlines.

So a table like

| 1 | 2 | 4 | 5 |
|---+---+---+---|
| a | b | c | d |
| e | f | g | h |

will be transposed as

| 1 | a | e |
| 2 | b | f |
| 4 | c | g |
| 5 | d | h |

Note that horizontal lines disappear.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-table.el.gz
(defun org-table-transpose-table-at-point ()
  "Transpose Org table at point and eliminate hlines.
So a table like

| 1 | 2 | 4 | 5 |
|---+---+---+---|
| a | b | c | d |
| e | f | g | h |

will be transposed as

| 1 | a | e |
| 2 | b | f |
| 4 | c | g |
| 5 | d | h |

Note that horizontal lines disappear."
  (interactive)
  (let* ((table (delete 'hline (org-table-to-lisp)))
	 (dline_old (org-table-current-line))
	 (col_old (org-table-current-column))
	 (contents (mapcar (lambda (_)
			     (let ((tp table))
			       (mapcar
				(lambda (_)
				  (prog1
				      (pop (car tp))
				    (setq tp (cdr tp))))
				table)))
			   (car table))))
    (goto-char (org-table-begin))
    (re-search-forward "|")
    (backward-char)
    (delete-region (point) (org-table-end))
    (insert (mapconcat
	     (lambda(x)
	       (concat "| " (mapconcat 'identity x " | " ) "  |\n" ))
	     contents ""))
    (org-table-goto-line col_old)
    (org-table-goto-column dline_old))
  (org-table-align))