emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bug#47885: [PATCH] org-table-import: Make it more smarter for intera


From: Maxim Nikulin
Subject: Re: bug#47885: [PATCH] org-table-import: Make it more smarter for interactive use
Date: Thu, 13 May 2021 00:08:35 +0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1

On 11/05/2021 01:36, Utkarsh Singh wrote:
What do we mean by interactive preview?  Does this mean that we should
present a user with a list of possible delimiters using minibuffer?

I mean something like the dialog that LibreOffice shows on opening of a csv file. There are various options and table preview that allows to check if options are selected correctly before dropping to usual spreadsheet interface. I have no idea what is the best way to implement something like this in emacs. Likely it is out of scope of the discussed patch. I do not know what is your use cases. My intention was to show that CSV import could be quite cumbersome.

Some users believe that CSV is a reliable portable format and expect support of most features from Excel. Actually there are plenty of dialects and no way to determine which one was used (e.g. no header that defines field or string separator).

For ex (please review my usage of alist):

#+begin_src elisp
(defvar my-separator-alist '(("comma" . ",")
                             ("tab" . "\t")
                             ("semicolon" . ";")
                             ("colon" . ":")
                             ("space" . " ")))

(defun my/table-import (file separator)
   (interactive (list (read-file-name "Import CSV file: " nil nil t)
                     (cdr (assoc (completing-read "Separator: " 
my-separator-alist)
                                 my-separator-alist))))
   (org-table-import file separator))
#+end_src

With such function it is necessary to open file at first to see what separator is used inside.

My comments were related to the "guess" part of your patch. Comma is tried first. Consider the following file

A;1,2;3,4;5,6
B;7,8;9,1;11,12
C;13,14;15,16;17,18

Decimal separator is ",". Field separator is ";" but there are plenty of "," in each row.

LANG=fr_FR.UTF-8 python3 -c "import locale as l; l.setlocale(l.LC_ALL, ''); print(l.format_string('%.2f', 123456.789))"
123456,79

Comma is decimal separator for es_ES, de_DE, ru_RU, etc. The point is that order in which separator candidates are tried should depend on active locale.

I do not insist that interactive preview or smarter approach to guess separator have to be implemented. Feel free to disregard my comments. I am just not sure whether you are aware of limitations for noticeable part of users.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]