From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: Re: [PATCH] quote the real csv separator Date: Mon, 25 Oct 2010 11:06:31 +0200 Message-ID: <627E784E-E564-4604-A644-1D7CBC1597F8@gmail.com> References: <87mxq4wman.fsf@kotik.lan> <57E157F5-BDE7-4431-B15F-8EE52E571677@gmail.com> <871v7f8gfl.fsf@kotik.lan> <87tykbqd1v.fsf@gollum.intra.norang.ca> <87zku2mzjn.fsf@dasa3.iem.pw.edu.pl> Mime-Version: 1.0 (Apple Message framework v936) Content-Type: text/plain; charset=UTF-8; format=flowed; delsp=yes Content-Transfer-Encoding: quoted-printable Return-path: Received: from [140.186.70.92] (port=59969 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PAJ8K-0000Gz-9b for emacs-orgmode@gnu.org; Mon, 25 Oct 2010 05:14:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PAJ0m-0007ei-45 for emacs-orgmode@gnu.org; Mon, 25 Oct 2010 05:06:38 -0400 Received: from mail-ey0-f169.google.com ([209.85.215.169]:65386) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PAJ0l-0007ed-Vl for emacs-orgmode@gnu.org; Mon, 25 Oct 2010 05:06:36 -0400 Received: by eydd26 with SMTP id d26so1292906eyd.0 for ; Mon, 25 Oct 2010 02:06:35 -0700 (PDT) In-Reply-To: <87zku2mzjn.fsf@dasa3.iem.pw.edu.pl> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: =?UTF-8?Q?=C5=81ukasz_Stelmach?= Cc: emacs-orgmode@gnu.org On Oct 25, 2010, at 10:45 AM, =C5=81ukasz Stelmach wrote: > Bernt Hansen writes: > >> =C5=81ukasz Stelmach writes: >>> Carsten Dominik 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 =20 >>> 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 =20 >> delimited >> data into your org file, select the region and C-c | to get your =20 >> table. >> >> If you are inserting an external file with C-x i 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 =20 > 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. =20= > 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 =20= > how > to quote it. orgtbl-to-generic is, well, very generic. It is up to the caller that =20= when she/he specified :sep, to ensure the the separator does not show =20= up in fields, of to specify :fmt in a way that it will take care of =20 any necessary quoting. There is no generic way of quoting, sometimes =20= it is prepending a character, bu in other cases something completely =20 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 =20 > 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 =20 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 =20 saying. Best wishes - Carsten