From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 2EoLCeALnGAAaQAAgWs5BA (envelope-from ) for ; Wed, 12 May 2021 19:09:52 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id 4O7CBOALnGDbPgAA1q6Kng (envelope-from ) for ; Wed, 12 May 2021 17:09:52 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 77147196DE for ; Wed, 12 May 2021 19:09:51 +0200 (CEST) Received: from localhost ([::1]:40646 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgsMo-0006D7-Jp for larch@yhetil.org; Wed, 12 May 2021 13:09:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57288) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgsLn-0005Uc-Mb for emacs-orgmode@gnu.org; Wed, 12 May 2021 13:08:49 -0400 Received: from ciao.gmane.io ([116.202.254.214]:58876) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgsLj-0002zw-Kn for emacs-orgmode@gnu.org; Wed, 12 May 2021 13:08:46 -0400 Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1lgsLh-00068e-IS for emacs-orgmode@gnu.org; Wed, 12 May 2021 19:08:41 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: emacs-orgmode@gnu.org 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 Message-ID: References: <87czuq9958.fsf@gmail.com> <8735vmelfs.fsf@nicolasgoaziou.fr> <87k0oyfj4y.fsf@gmail.com> <87im4h9irn.fsf@nicolasgoaziou.fr> <87zgxpwqa7.fsf@gmail.com> <875z07jx6n.fsf@nicolasgoaziou.fr> <87tunqby9a.fsf@gmail.com> <875yzq77w8.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 In-Reply-To: <875yzq77w8.fsf@gmail.com> Content-Language: en-US Received-SPF: pass client-ip=116.202.254.214; envelope-from=geo-emacs-orgmode@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: 28 X-Spam_score: 2.8 X-Spam_bar: ++ X-Spam_report: (2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_ADSP_CUSTOM_MED=0.001, FORGED_GMAIL_RCVD=1, FORGED_MUA_MOZILLA=2.309, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, NICE_REPLY_A=-0.001, NML_ADSP_CUSTOM_MED=0.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1620839391; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=b7azkG7exLwDP7fvhmruzjoQPrYtoE3sctpDw8XXBck=; b=u2VCYtzP+uCZK1S3TZkWQqCFrcP/zZ510UeZ2S6T9SWuoO4VculwXjSCSsdZxVQhKpfuP/ dzF6M/5WCcYAOhSvs4BG5XvfGmMIgX3GhO4aNx+HALhnqFikBIn4Mfgj2rzPxInerV0aU8 FcXgu2KMbE2oqF13Awk/RUWlntZZ2WZj4VHi1Z0ZIErxThn5tgs7laI9/dUJ6rKOr2qvAp xSCF4u+zkZok7ByrSlGkeOxoDwAG1gQRYFCOZnITfiFmSJrWAuaxBQi1Bg5Phgwv8yz5Lo jRLkmVtSaAPW2S4Whedgr+L6YCI0mDlELV4F2st/job2PfYvRmwJExSZRr6M0g== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1620839391; a=rsa-sha256; cv=none; b=imIb1dhdTRJn1AL0wiM5FWilkdWTv2f9aMiuH62k5eU9LaJQDcKxzkIQ3PVwnxj4R3wuKh t1/rRUBWcNsKJhEv3sLNlXmSr7cXf12AeO/e6Rbrhahkm5tViNQLCxlBPeS5W5QmQ38whp pjtyDkh280gYUby7SE2nuQb/0O0kSDiU9UYc45ZYuetahNLCem3FqwYKGVPViBA/46dtuA H8hRjQc8AAOXO86EDWw3BWJSkMcbC1lmq/iiTzcjs6MVgpmuGCCTQ6sAVLvaoKtkay04Bl QyFHKX7jZkks2njZt40jRyUvlVlTc20P9bFszFYb9z81t2oiSqFvtnsDgrr9sg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Spam-Score: -1.85 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: 77147196DE X-Spam-Score: -1.85 X-Migadu-Scanner: scn0.migadu.com X-TUID: VSADwTIU5pEa 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.