* Proposed patch for customizable org-table-export
@ 2008-10-29 3:24 Colin Williams
2008-10-29 17:41 ` Bernt Hansen
0 siblings, 1 reply; 2+ messages in thread
From: Colin Williams @ 2008-10-29 3:24 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1.1: Type: text/plain, Size: 955 bytes --]
I've created the custom variable org-table-export-delimiter so that the user
may customize the string that delimits the columns exported.
I believe this is useful because in some areas (namely, my office) people
insist on the files being in csv (comma separated values).
I've also noticed (but haven't bothered fixing yet) that if a field contains
the delimiter string (be it a tab or a comma), then the resulting exported
file has misaligned columns. In csv format, this is remedied by surround
the offending columns in double quotes. I'm not sure, but I believe tab
separated format usually handles separator character disambiguation in a
similar way.
I've attached the patch for my change, but as this patch is the first thing
I've contributed to org-mode, I'm still waiting on the paperwork from the
gnu foundation. Also, I've actually never contributed a patch to a free
project before, so I'm sorry if the patch file is incorrectly formatted.
[-- Attachment #1.2: Type: text/html, Size: 1030 bytes --]
[-- Attachment #2: org.el.patch --]
[-- Type: application/octet-stream, Size: 850 bytes --]
--- org.el~ 2008-05-05 23:09:50.000000000 -0400
+++ org.el 2008-10-28 22:50:18.204880700 -0400
@@ -8510,6 +8510,11 @@ are found, lines will be split on whites
(insert-file-contents file)
(org-table-convert-region beg (+ (point) (- (point-max) pm)) arg)))
+(defcustom org-table-export-delimiter "\t"
+ "The default separator for exported tables."
+ :group 'org-table-settings
+ :type 'string)
+
(defun org-table-export ()
"Export table as a tab-separated file.
Such a file can be imported into a spreadsheet program like Excel."
@@ -8542,7 +8547,7 @@ Such a file can be imported into a sprea
(delete-char 1)))
(goto-char (point-min))
(while (re-search-forward "[ \t]*|[ \t]*" nil t)
- (replace-match "\t" t t))
+ (replace-match org-table-export-delimiter t t))
(save-buffer))
(kill-buffer buf)))
[-- Attachment #3: Type: text/plain, Size: 204 bytes --]
_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Proposed patch for customizable org-table-export
2008-10-29 3:24 Proposed patch for customizable org-table-export Colin Williams
@ 2008-10-29 17:41 ` Bernt Hansen
0 siblings, 0 replies; 2+ messages in thread
From: Bernt Hansen @ 2008-10-29 17:41 UTC (permalink / raw)
To: Colin Williams; +Cc: emacs-orgmode
"Colin Williams" <lackita@gmail.com> writes:
> I've created the custom variable org-table-export-delimiter so that the user
> may customize the string that delimits the columns exported.
>
> I believe this is useful because in some areas (namely, my office) people
> insist on the files being in csv (comma separated values).
>
> I've also noticed (but haven't bothered fixing yet) that if a field contains
> the delimiter string (be it a tab or a comma), then the resulting exported
> file has misaligned columns. In csv format, this is remedied by surround
> the offending columns in double quotes. I'm not sure, but I believe tab
> separated format usually handles separator character disambiguation in a
> similar way.
>
> I've attached the patch for my change, but as this patch is the first thing
> I've contributed to org-mode, I'm still waiting on the paperwork from the
> gnu foundation. Also, I've actually never contributed a patch to a free
> project before, so I'm sorry if the patch file is incorrectly formatted.
My version of org-mode already exports in CSV format just fine.
I create a test file
,----[ x.org ]
| | Z | B | C | D |
| |-------+-------+-------+---------|
| | 1 | 2 | 3 | 4 |
| | 7,234 | 7,222 | 154.0 | 11 |
| | abc | def | ghi | jkl,lmn |
`----
M-x org-table-export
prompts for a filename (x.csv)
and a format orgtbl-to-csv
and I get this
,----[ x.csv ]
| Z,B,C,D
| 1,2,3,4
| "7,234","7,222",154.0,11
| abc,def,ghi,"jkl,lmn"
`----
I have the following settings in my .emacs since I export to CSV by
default
,----
| (setq org-table-export-default-format "orgtbl-to-csv")
`----
Org-mode version 6.10c (release_6.10c-20-g17c55f1 <- from git describe)
which is 20 commits after the release_6.10c tag on commit
17c55f1b10b2ad77b830bc057c722ffc99611337
^^^^^^^
This has been available for a long time I believe.
-Bernt
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-10-29 17:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-29 3:24 Proposed patch for customizable org-table-export Colin Williams
2008-10-29 17:41 ` Bernt Hansen
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).