From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: Import CSV file, remove columns, print table Date: Fri, 13 Sep 2019 09:42:15 -0400 Message-ID: References: <87r24knwwi.fsf@hornfels.zedat.fu-berlin.de> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000ef7a1c05926f6cf7" Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:38828) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i8lqL-0001xr-M0 for emacs-orgmode@gnu.org; Fri, 13 Sep 2019 09:42:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i8lqK-0005i8-6v for emacs-orgmode@gnu.org; Fri, 13 Sep 2019 09:42:33 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]:53108) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i8lqJ-0005hP-Py for emacs-orgmode@gnu.org; Fri, 13 Sep 2019 09:42:32 -0400 Received: by mail-wm1-x330.google.com with SMTP id x2so2849372wmj.2 for ; Fri, 13 Sep 2019 06:42:31 -0700 (PDT) In-Reply-To: <87r24knwwi.fsf@hornfels.zedat.fu-berlin.de> 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: Loris Bennett Cc: org-mode-email --000000000000ef7a1c05926f6cf7 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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=C3=A4t 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=3Dcsv (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=C3=A4t 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. > > > --000000000000ef7a1c05926f6cf7 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
You can do something like this:

#+name:= csv
| ID | Name =C2=A0 =C2=A0 =C2=A0 =C2=A0 | Titel / Title | Vorname /= First Name | Nachname / Surname | Institution =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 |
| =C2=A01 | Alice Apple =C2=A0| Fr./Ms. =C2=A0 =C2=A0 =C2=A0 | = Alice =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| Apple =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| Universit=C3=A4t zum Apfel || =C2=A02 | Bob Birne =C2=A0 =C2=A0| Hr./Mr. =C2=A0 =C2=A0 =C2=A0 | Bob = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| Birne =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| Pear University =C2=A0 =C2= =A0 =C2=A0 |
| =C2=A03 | Carol Carrot | Prof. =C2=A0 =C2=A0 =C2=A0 =C2= =A0 | Carol =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| Carrot= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | University of Veg =C2=A0 =C2= =A0 |


#+BEGIN_SRC emacs-lisp :var data=3Dcsv
(let ((table (ma= pcar (lambda (row) (list (nth 0 row) (nth 4 row) (nth 3 row))) data)))
= =C2=A0 (setf (car table) (append (car table) '("Signature")))=
=C2=A0 table)
#+END_SRC

#+RESULTS:
| ID | Nachname / Surn= ame | Vorname / First Name | Signature |
| =C2=A01 | Apple =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| Alice =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0| =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |
| =C2=A02= | Birne =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| Bob =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 |
| =C2=A03 | Carrot =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 | Carol =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |


John

= -----------------------------------
Professor John Kitchin=C2=A0
Dohe= rty Hall A207F
Department of Chemical Engineering
Carnegie Mellon Uni= versity
Pittsburgh, PA 15213
412-268-7803
=

On Fri, Sep 13, 2019 at 9:36 AM Loris Bennett <loris.bennett@fu-berlin.de> 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=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| Titel / Title | Vorname / Fi= rst Name | Nachname / Surname | Institution=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0|
|=C2=A0 1 | Alice Apple=C2=A0 | Fr./Ms.=C2=A0 =C2=A0 =C2=A0 =C2=A0| Alice= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | Apple=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | Universit=C3=A4t zum Apfel |
|=C2=A0 2 | Bob Birne=C2=A0 =C2=A0 | Hr./Mr.=C2=A0 =C2=A0 =C2=A0 =C2=A0| Bo= b=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | Birne=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | Pear University=C2=A0 =C2= =A0 =C2=A0 =C2=A0|
|=C2=A0 3 | Carol Carrot | Prof.=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| Carol= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | Carrot=C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| University of Veg=C2=A0 =C2=A0 =C2= =A0|


I would like to reduce this to

| ID | Nachname / Surname | Vorname / First Name | Signature |
|=C2=A0 1 | Apple=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | Alice= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0|
|=C2=A0 2 | Birne=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | Bob=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0|
|=C2=A0 3 | Carrot=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| Carol= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0|

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.


--000000000000ef7a1c05926f6cf7--