1

I have created a excel file with Name,Title,Designation,Department,Faculty,Institute,TelNo,Email id columns

I want section wise telephone directory, i.e., We have 16 Faculties. So I want to create a Chapter/section title such as "Faculty of xyz" and under it Section or Subsections like "Department of abc" and below it the names of faculty members with their telephone numbers.

Is it possible to create such a Directory?

1 Answers1

3

The csvsimple package is for you. Given an archive in .csv format you can obtain a table (tabular or longtable) containing only the data required. In the example below I used the filter equal key to print only the rows that match a certain value in the "Department" column (which is the forth column, so \csvcoliv). I preferred to use a longtable environment as I expect some tables to span two pages (or more).

\documentclass{article}
\usepackage[a4paper,margin=1cm]{geometry}
\usepackage{csvsimple}
\usepackage{longtable}

\begin{filecontents}[overwrite]{test.csv} Name,Title,Designation,Department,Faculty,Institute,TelNo,EmailID Isaak Bacharach,Doctor,Foo,Mathematics,Science,Foo,234234123,foo@gmail.com Reinhold Baer,Professor,Foo,Chemics,Science,Foo,234234123,loo@gmail.com Christian Bär,Doctor,Loo,Physics,Science,Loo,234234123,foogmail.com Wolf Barth,Professor,Foo,Physics,Science,Foo,234234123,loo@gmail.com Friedrich L. Bauer,Professor,Loo,Chemics,Science,Loo,234234123,foogmail.com August Beer,Doctor,Foo,Sociology,Literature,Foo,234234123,loo@gmail.com Walter Benz,Professor,Loo,Physics,Science,Loo,234234123,foogmail.com Rudolf Berghammer,Professor,Foo,Sociology,Literature,Foo,234234123,loo@gmail.com Felix Bernstein,Professor,Loo,Physics,Science,Loo,234234123,foogmail.com Ludwig Berwald,Doctor,Foo,Philosophy,Literature,Foo,234234123,loo@gmail.com Karl Bobek,Professor,Loo,Sociology,Literature,Loo,234234123,foogmail.com Friedrich Böhm,Doctor,Foo,Philosophy,Literature,Foo,234234123,loo@gmail.com Oskar Bolza,Professor,Loo,Chemics,Science,Loo,234234123,foogmail.com Karl-Heinz Boseck,Professor,Foo,Chemics,Science,Foo,234234123,loo@gmail.com Hermann Bottenbruch,Doctor,Loo,Philosophy,Literature,Loo,234234123,foogmail.com \end{filecontents}

\newcommand{\getphonelist}[1]{% \begin{longtable}[l]{lll} \bfseries Person & \bfseries Tel.~No. & \textbf{Email ID} \csvreader[head to column names,filter equal={\csvcoliv}{#1}]{test.csv}{}% {\ \Name & \TelNo & \texttt{\EmailID}} \end{longtable}}

\begin{document}

\csvautolongtable{test.csv}

\section{Faculty of Science} \subsection{Department of Mathematics} \getphonelist{Mathematics}

\subsection*{Department of Physics} \getphonelist{Physics}

\section{Faculty of Literature} \subsection{Department of Philosophy} \getphonelist{Philosophy}

\subsection*{Department of Sociology} \getphonelist{Sociology}

\end{document}

Ivan
  • 4,368
  • Thank you very much. It is working after several tries! I will return back if I have any doubts. – Duvvuri Venu Gopal Jan 13 '21 at 14:22
  • The above example worked fine. My data has blanks so how to skip them. I have collected e-mail ids. But because of @ errors are coming and I am unable to include email id in the output. – Duvvuri Venu Gopal Jan 16 '21 at 13:37
  • I don't understand what you mean by "skip them". Do you want to ignore all lines that do not have complete data (for example, phon num missing)? With regard to the email addresses, I updated the example, including those too. The @ character doesn't seem to cause errors. – Ivan Jan 16 '21 at 14:32
  • This is the data : "Abhay Kumar Mishra ,Dr. ,Assoct. Professor,German Studies ,Arts,,,,9651713430,,End". Now wherever the field is blank it is shown by ",". In my output I am mixing two columns - OfficeLandNo and CUG Phone No; ResidenceLandNo and Mobile number separated by a "," In output If number column is blank then the "," should not come. I think it is possible with a boolean. Yes or No. If yes then how? – Duvvuri Venu Gopal Jan 18 '21 at 12:49