From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Loris Bennett" Subject: Re: Import CSV file, remove columns, print table Date: Mon, 16 Sep 2019 14:45:58 +0200 Message-ID: <87sgow1kah.fsf@hornfels.zedat.fu-berlin.de> References: <87r24knwwi.fsf@hornfels.zedat.fu-berlin.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:35433) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9qOU-0001bp-Bl for emacs-orgmode@gnu.org; Mon, 16 Sep 2019 08:46:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i9qOS-0008QN-Aw for emacs-orgmode@gnu.org; Mon, 16 Sep 2019 08:46:14 -0400 Received: from 195-159-176-226.customer.powertech.no ([195.159.176.226]:52888 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i9qOR-0008PQ-HK for emacs-orgmode@gnu.org; Mon, 16 Sep 2019 08:46:12 -0400 Received: from list by blaine.gmane.org with local (Exim 4.89) (envelope-from ) id 1i9qOM-000VJS-1K for emacs-orgmode@gnu.org; Mon, 16 Sep 2019 14:46:06 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org Hi John, Thanks - that's a nicely compact solution, albeit in the category 'source block' and in a language I'm not very skilled at :-) I realise that I have slightly misstated the problem. The ID in the imported CSV is just a key from the database - I don't need it on the list of participants. However, it would be nice to number the participants, who are sorted by surname. How would I insert a column which just numbers the row? Cheers, Loris John Kitchin writes: > You can do something like this: > > #+name: csv > | ID | Name | Titel / Title | Vorname / First Name | Nachname / Surname | Institution | > | 1 | Alice Apple | Fr./Ms. | Alice | Apple | Universität zum Apfel | > | 2 | Bob Birne | Hr./Mr. | Bob | Birne | Pear University | > | 3 | Carol Carrot | Prof. | Carol | Carrot | University of Veg | > > #+BEGIN_SRC emacs-lisp :var data=csv > (let ((table (mapcar (lambda (row) (list (nth 0 row) (nth 4 row) (nth 3 row))) data))) > (setf (car table) (append (car table) '("Signature"))) > table) > #+END_SRC > > #+RESULTS: > | ID | Nachname / Surname | Vorname / First Name | Signature | > | 1 | Apple | Alice | | > | 2 | Birne | Bob | | > | 3 | Carrot | Carol | | > > John > > ----------------------------------- > Professor John Kitchin > Doherty Hall A207F > Department of Chemical Engineering > Carnegie Mellon University > Pittsburgh, PA 15213 > 412-268-7803 > @johnkitchin > http://kitchingroup.cheme.cmu.edu > > On Fri, Sep 13, 2019 at 9:36 AM Loris Bennett wrote: > > Hi, > > I want to create a list of participants of an event which people can > sign, so that I can record who actually turned up. > > From the registration website I can download a CSV file and import it > into and org file: > > | ID | Name | Titel / Title | Vorname / First Name | Nachname / Surname | Institution | > | 1 | Alice Apple | Fr./Ms. | Alice | Apple | Universität zum Apfel | > | 2 | Bob Birne | Hr./Mr. | Bob | Birne | Pear University | > | 3 | Carol Carrot | Prof. | Carol | Carrot | University of Veg | > > I would like to reduce this to > > | ID | Nachname / Surname | Vorname / First Name | Signature | > | 1 | Apple | Alice | | > | 2 | Birne | Bob | | > | 3 | Carrot | Carol | | > > and then print it out as a LaTeX table. > > I can obviously write a source block of Python or R to do this, but can > I manipulate the table more directly in Org? > > Cheers, > > Loris > > -- > This signature is currently under construction. > -- Dr. Loris Bennett (Mr.) ZEDAT, Freie Universität Berlin Email loris.bennett@fu-berlin.de