How to convert org-mode table to original tab format?

I convert a region to a table using Cc | .

Is there a way to reverse the process, say, after the conversion, do some editing and go back to the original format (values ​​separated by tabs)?

I know that I can do this through org-table-export , but this is too cumbersome.

+6
source share
4 answers
  • Mark the area.
  • Mx replace-string
  • |
  • Cq TAB RET

If you want to configure it, use replace-regex .

+2
source

Try orgtbl-to-tsv for values ​​separated by tabs.

There is also orgtbl-to-csv for comma separated values.

For instance:

  * Some heading #+name: foo | a | b | c | |---+---+---| | 1 | 2 | 3 | | 4 | 5 | 6 | #+BEGIN_SRC elisp :var x=foo (orgtbl-to-csv x nil) #+END_SRC #+RESULTS: : 1,2,3 : 4,5,6 
+4
source

Below are the steps for using table export as tab or comma values:

  • Use the org-table-export command. Mx org-table-export
  • Enter the file name to save (or press Enter for the same file).
  • Choose a format (here you can set the format orgtbl-to-tsv or any other formats).

Here are some of the formats you can use:

  • orgtbl to csv
  • orgtbl to generic
  • orgtbl to HTML
  • orgtbl to latex
  • orgtbl to orgtbl
  • orgtbl to Texinfo
  • orgtbl to TSV
+2
source

I need this too, and I wrote the following based on org-table-export:

 (defun org-table-transform-in-place () "Just like `ORG-TABLE-EXPORT', but instead of exporting to a file, replace table with data formatted according to user's choice, where the format choices are the same as org-table-export." (interactive) (unless (org-at-table-p) (user-error "No table at point")) (org-table-align) (let* ((format (completing-read "Transform table function: " '("orgtbl-to-tsv" "orgtbl-to-csv" "orgtbl-to-latex" "orgtbl-to-html" "orgtbl-to-generic" "orgtbl-to-texinfo" "orgtbl-to-orgtbl" "orgtbl-to-unicode"))) (curr-point (point))) (if (string-match "\\([^ \t\r\n]+\\)\\( +.*\\)?" format) (let ((transform (intern (match-string 1 format))) (params (and (match-end 2) (read (concat "(" (match-string 2 format) ")")))) (table (org-table-to-lisp (buffer-substring-no-properties (org-table-begin) (org-table-end))))) (unless (fboundp transform) (user-error "No such transformation function %s" transform)) (save-restriction (with-output-to-string (delete-region (org-table-begin) (org-table-end)) (insert (funcall transform table params) "\n"))) (goto-char curr-point) (beginning-of-line) (message "Tranformation done.")) (user-error "Table export format invalid")))) (define-key org-mode-map (kbd "\Cx |") 'org-table-transform-in-place) 

It would be great if this were added to org-mode, as I think many of them will use it.

0
source

Source: https://habr.com/ru/post/949716/


All Articles