Time table with GNU Emacs


It's not a very well kept secret that Emacs is an extensible editor and can be even extended to manage your university time table. My university originally uses MS Excel files to distribute time tables which are pain to work with. So I decided to use Emacs built-in Org mode table editor to interact with time table with added benefit of being plain text.

Covert MS Excel file to CSV

MS Excel files can be easily converted to CSV file from any application but for this presentation I will use Libreoffice.

First open a MS Excel file in and new Libreoffice session and then by pressing C-s you will be presented with following options, choose CSV as file extension and then save the file.

Figure 1: Libreoffice Save Dialog

Importing CSV files to Emacs

Out the box Emacs comes with several methods to import a CSV file and present it as a spreadsheet or a simple plain text table. In this case I needed a subtle combination of importing and filtering because the file I am going to import contains time table for all the batches.

Here is the section presenting all the class scheduled for Monday:

Mon,L-18B11BI312 BI41 (RST) CR9,L-18B11CI415 BI41 (MBI) TR1,L-18B11BT313 BT41 (PNS) CR11,
,"L-18B11CI413 CS41-CS48,IT41-42 (RSU) TR1","L-18B11MA313 CS41-CS48,IT41-42 (SST) ECL9",
,,,P-18B17EC373 EC42 (MSD) ECL8,P-18B17EC373 EC42 (MSD) ECL8,,P-18B17EC371 EC41 (EMP) CL10,P-18B17EC371 EC41 (EMP) CL10,,
,,,P-18B17CI372 IT41 (PDG) CL1,P-18B17CI372 IT41 (PDG) CL1,,P-18B17BI473 BI41 (RJK) BIL,P-18B17BI473 BI41 (RJK) BIL,,
,,,P-18B17CI372 CS48 (NFK) CL3_1,P-18B17CI372 CS48 (NFK) CL3_1,,P-18B11CE413 CE41 (TNM) WORK2,P-18B11CE413 CE41 (TNM) WORK2,,
,,,P-18B17CI372 IT42 (PKJ) CL3_2,P-18B17CI372 IT42 (PKJ) CL3_2,,,P-18B17BT373 BT41 (PNS) UG2,P-18B17BT373 BT41 (PNS) UG2,
,,,P-18B17CI473 CS46 (RSU) CL4,P-18B17CI473 CS46 (RSU) CL4,,,,P-18B17CI372 CS42 (SLD) CL1,P-18B17CI372 CS42 (SLD) CL1
,,,P-18B17CI373 CS41 (HRI) CL5_1,P-18B17CI373 CS41 (HRI) CL5_1,,,,P-18B17CI372 CS41 (VKB) CL3_1,P-18B17CI372 CS41 (VKB) CL3_1
,,,P-18B17CI373 CS42 (PTK) CL5_2,P-18B17CI373 CS42 (PTK) CL5_2,,,,P-18B17CI473 CS44 (PKG) CL3_2,P-18B17CI473 CS44 (PKG) CL3_2
,,,P-18B17CI373 CS43 (EGA) CL6,P-18B17CI373 CS43 (EGA) CL6,,,,P-18B17CI473 CS43 (RKI) CL4,P-18B17CI473 CS43 (RKI) CL4
,,,P-18B17CI373 CS44 (HES) CL7,P-18B17CI373 CS44 (HES) CL7,,,,P-18B17CI373 CS46 (PMI) CL5_1,P-18B17CI373 CS46 (PMI) CL5_1
,,,P-18B17CI373 CS45 (MBI) CL8,P-18B17CI373 CS45 (MBI) CL8,,,,P-18B17CI373 CS47 (AMN) CL5_2,P-18B17CI373 CS47 (AMN) CL5_2
,,,P-18B17CI473 CS47 (MSH) CL9_1,P-18B17CI473 CS47 (MSH) CL9_1,,,,P-18B17CI373 CS48 (JAG) CL6,P-18B17CI373 CS48 (JAG) CL6
,,,P-18B11CI474 BI41 (SJT) CL11,P-18B11CI474 BI41 (SJT) CL11,,,,P-18B17CI373 IT41 (HJL) CL7,P-18B17CI373 IT41 (HJL) CL7
,,,P-18B17CE472 CE41 (SUB) ENVLAB,P-18B17CE472 CE41 (SUB) ENVLAB,,,,P-18B17CI373 IT42 (AKJ) CL8,P-18B17CI373 IT42 (AKJ) CL8
,,,,,,,,P-18B17CI473 CS45 (ARV) CL9_1,P-18B17CI473 CS45 (ARV) CL9_1

So I wrote ttable.el which does exactly that with the help of Masahiro Hayashi's pcsv library which Sasha Chua guided me to. Now to convert CSV file into a aesthetically pleasing time table you have to insert M-x ttable-create which will present it into an Org mode table and also removing classes which I am not interested in. Here is a sample output:

Figure 2: Org-mode time table


This article was written to emphasize on Emacs biggest feature it's extensibility. Emacs elegantly extended itself to present CSV files as spreadsheet-like tables. In the process I also learned how to choose a optimal data structure for a give purpose (string -> vectors) which solved most of my problems of formatting and speed.