[Orgmode] Re: [PATCH] quote the real csv separator
Bernt Hansen be...@norang.ca writes: Łukasz Stelmach lukasz.stelm...@iem.pw.edu.pl writes: Carsten Dominik carsten.domi...@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. 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). -- Miłego dnia, Łukasz Stelmach ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
[Orgmode] Re: [PATCH] quote the real csv separator
Hi all, Carsten Dominik wrote: Hi Lukasz, thanks for the patch, but I do not understand it. The separator for csv is always the comma, or am I wrong here? So this function should use comma, hard-coded. Just to confirm what has been implictly shown by Nick, the separator can be many things, and is not limited to comma and tab. By default, on a Windows with French locale settings, the separator is the semi-colon... certainly because the comma is used as decimal separator. Best regards, Seb -- Sébastien Vauban ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
Re: [Orgmode] Re: [PATCH] quote the real csv separator
On Oct 25, 2010, at 10:45 AM, Łukasz Stelmach wrote: Bernt Hansen be...@norang.ca writes: Łukasz Stelmach lukasz.stelm...@iem.pw.edu.pl writes: Carsten Dominik carsten.domi...@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 ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
[Orgmode] Re: [PATCH] quote the real csv separator
Carsten Dominik carsten.domi...@gmail.com writes: On Oct 25, 2010, at 10:45 AM, Łukasz Stelmach wrote: 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. OK, try to eval these: (let ((params '(:sep |))) (org-combine-plists '(:sep , :fmt org-quote-csv-field) params)) (let ((params '(:sep |))) (org-combine-plists params '(:sep , :fmt org-quote-csv-field))) The latter prevents :sep from being overriden. -- Miłego dnia, Łukasz Stelmach ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
[Orgmode] Re: [PATCH] quote the real csv separator
Carsten Dominik carsten.domi...@gmail.com writes: On Oct 24, 2010, at 12:56 AM, Łukasz Stelmach wrote: I'd rather use an optional sep argument to the org-quote-csv-field function but I've got no idea how to stick it into the orgtbl-apply- fmt. However, the quoting function should use current rather then assume comma. [...] thanks for the patch, but I do not understand it. The separator for csv is always the comma, or am I wrong here? A bit. The fact is that both OpenOffice (i've just checked) and Microsoft Office (I am almost 100% sure) allow to choose the separator upon export. And org-mode also allows it with radio tables with the :sep parameter (which is passed to the generic exporter). So this function should use comma, hard-coded. The only place where it is used is when orgtbl-to-csv calls the generic exporter. It does so with comma as separator and with org-quote-csv-field as formatting function. What use case do you have in mind? For me in particular? This is quite complicated ;-) And if you decide to reject the patch I will understand. (Read only I you have some time to waste ;) 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. The reports from the bank are prepared for each account independently. When I transfer money between them I get entries in two reports. To get rid of this mess I decided to write a perl programme and I do it. And I prepare test data as radio tables and export them using pipe (yeah I know, this doesn't make a good point in favour of my patch) because... I prefer to manipulate all my bank report data with org-mode as tables. *My* use case isn't very good, is it? -- Miłego dnia, Łukasz Stelmach ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode
[Orgmode] Re: [PATCH] quote the real csv separator
Łukasz Stelmach lukasz.stelm...@iem.pw.edu.pl writes: Carsten Dominik carsten.domi...@gmail.com writes: On Oct 24, 2010, at 12:56 AM, Łukasz Stelmach wrote: I'd rather use an optional sep argument to the org-quote-csv-field function but I've got no idea how to stick it into the orgtbl-apply- fmt. However, the quoting function should use current rather then assume comma. [...] thanks for the patch, but I do not understand it. The separator for csv is always the comma, or am I wrong here? A bit. The fact is that both OpenOffice (i've just checked) and Microsoft Office (I am almost 100% sure) allow to choose the separator upon export. And org-mode also allows it with radio tables with the :sep parameter (which is passed to the generic exporter). So this function should use comma, hard-coded. The only place where it is used is when orgtbl-to-csv calls the generic exporter. It does so with comma as separator and with org-quote-csv-field as formatting function. What use case do you have in mind? For me in particular? This is quite complicated ;-) And if you decide to reject the patch I will understand. (Read only I you have some time to waste ;) 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. If this works better for you then I would suggest dropping the patch. Regards, Bernt ___ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode