1

Please, help! I use literate programming and I want to use org-mode tables as data for my R code blocks. However, when it comes to cell values that have meaningful leading and trading spaces org-mode either removes it or escapes the quotes. I would very like to leave such spaces in place when I quote the value in the org table cell.

Example:

#+name: test-table
| name      | string                                                            |
|-----------+-------------------------------------------------------------------|
| example-1 | "  a string with very important leading and trailing spaces "     |
| example-2 | ""  a string with very important leading and trailing spaces ""   |
| example-3 | """  a string with very important leading and trailing spaces """ |
| example-4 | \"  a string with very important leading and trailing spaces \"   |
| example-5 | '  a string with very important leading and trailing spaces '     |
| example-6 | \'  a string with very important leading and trailing spaces \'   |
#+header: :var data = test-table
#+begin_src R  :tangle no :results verbatim
  ## get value column and quote it to see if spaces are in place
  paste0("\"", data[[2]], "\"")
#+end_src

It gives me the following results:

#+RESULTS:
: "a string with very important leading and trading spaces"
: ""
: ""
: "\"  a string with very important leading and trading spaces \""
: "'  a string with very important leading and trading spaces '"
: "\'  a string with very important leading and trading spaces \'"

What I would like to have is just a string as it was in the table. Like this:

: "  a string with very important leading and trading spaces "

I looked where it gets trimmed and I think it is somewhere in orgtbl-to-generic function, but it converts the table (in lisp format) back to org table and uses custom export backend to print it to tsv. I could not figure out where it removes the spaces and how to fix it. It might be a bug. I think that normal behavior should be the one that I was expected initially.

Can you, please, help me with getting around it?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.