emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Carsten Dominik <carsten.dominik@gmail.com>
To: "Łukasz Stelmach" <lukasz.stelmach@iem.pw.edu.pl>
Cc: emacs-orgmode@gnu.org
Subject: Re: Re: [PATCH] quote the real csv separator
Date: Mon, 25 Oct 2010 11:06:31 +0200	[thread overview]
Message-ID: <627E784E-E564-4604-A644-1D7CBC1597F8@gmail.com> (raw)
In-Reply-To: <87zku2mzjn.fsf@dasa3.iem.pw.edu.pl>


On Oct 25, 2010, at 10:45 AM, Łukasz Stelmach wrote:

> Bernt Hansen <bernt@norang.ca> writes:
>
>> Łukasz Stelmach <lukasz.stelmach@iem.pw.edu.pl> writes:
>>> Carsten Dominik <carsten.dominik@gmail.com> writes:
>>>> What use case do you have in mind?
> [...]
>>> My bank lets me download monthly reports as CSV. In fact they let me
>>> choose the separator and the default value is the comma. But I  
>>> choose
>>> '|' because then I can open the csv as org file and just do
>>>
>>> (replace-regexp "^" "|")
>>>
>>> to get a beautiful org-mode table.
>>
>> There is an easier org-mode way I think.  Just get the comma  
>> delimited
>> data into your org file, select the region and C-c | to get your  
>> table.
>>
>> If you are inserting an external file with C-x i <file> RET
>> then C-x C-x marks the region and C-c | converts it to a table.
>
> Cool :-) It works like charm. I'll have to check how to convert  
> decimal
> commas to periods. I still like '|' more for my perl script, though,
> because it's enough to split '\|' and not care about quoted commas.  
> But
> this is my problem.
>
> OK, I won't insist on keeping the patch but I would like to get a
> rationale of :sep parameter in orgtbl-to-generic without a choice of  
> how
> to quote it.

orgtbl-to-generic is, well, very generic.  It is up to the caller that  
when she/he specified :sep, to ensure the the separator does not show  
up in fields, of to specify :fmt in a way that it will take care of  
any necessary quoting.  There is no generic way of quoting, sometimes  
it is prepending a character, bu in other cases something completely  
different might be needed.

> OR, if you think that CSV should stay as it is then I
> suggest such a rewrite:
>
> (defun orgtbl-to-csv (table params)
>  (orgtbl-to-generic table (org-combine-plists
>                            params
> 			    '(:sep "," :fmt org-quote-csv-field))))
>
> to make CSV :sep and and :fmt mandatory (that's how this all have  
> starded).

I don't understand, here is the current definition of orgtbl-to-csv:

(defun orgtbl-to-csv (table params)
   "Convert the orgtbl-mode table to CSV material.
This does take care of the proper quoting of fields with comma or  
quotes."
   (orgtbl-to-generic table (org-combine-plists
			    '(:sep "," :fmt org-quote-csv-field)
			    params)))

so these are mandatory.  I guess I do not understand what you are  
saying.

Best wishes

- Carsten

  reply	other threads:[~2010-10-25  9:14 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-23 22:56 [PATCH] quote the real csv separator Łukasz Stelmach
2010-10-24 16:26 ` Carsten Dominik
2010-10-24 16:52   ` Nick Dokos
2010-10-24 19:37     ` Carsten Dominik
2010-10-25 10:32     ` Stefan Vollmar
2010-10-24 20:49   ` Łukasz Stelmach
2010-10-25  1:25     ` Bernt Hansen
2010-10-25  8:45       ` Łukasz Stelmach
2010-10-25  9:06         ` Carsten Dominik [this message]
2010-10-25 11:59           ` Łukasz Stelmach
2010-10-25  9:15   ` Sébastien Vauban

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=627E784E-E564-4604-A644-1D7CBC1597F8@gmail.com \
    --to=carsten.dominik@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=lukasz.stelmach@iem.pw.edu.pl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).