I have a CSV file that has many rows. I want to typeset these rows into a table using longtable
and datatool
package.
- However just before before the "lastfoot" (which says concluded) I am getting an empty row which I do not want. How to remove that extra row?
- The columns are not equally spaced under the dates. Somebody please help me to make them equally spaced.
I am giving the sample code. The name of my CSV file is namelist.csv
and it looks like this.
number,degree,Name
1,Dr,Abdul Ali
2,Mrs,Francesca Joestar
3,Mr,Chan Ker Mei
4,Dr,Hikaru Yagami
5,Dr,Harish Kumar
My LaTeX code is below.
\documentclass[12pt]{article}
\usepackage{setspace}
\usepackage{bookman}
\usepackage{longtable}
\usepackage{pdflscape}
\usepackage[a4paper,left=1in,right=0.8in,top=0.5in,bottom=0.5in]{geometry}
\usepackage{tgschola}
\usepackage{microtype}
\usepackage{datatool}
\DTLloaddb{names}{namelist.csv}
%==================================================================
\begin{document}
%
\begin{landscape}
%
\doublespacing
%
\begin{longtable}{|l|l|c|c|r|r|r|c|c|c|c|c|c|c|c|c|c|c|}\hline
%
No.&\multicolumn{1}{c|}{Name}& \multicolumn{2}{c|}{13.12.2010}&
\multicolumn{2}{c|}{14.12.2010}&\multicolumn{2}{c|}{15.12.2010}&
\multicolumn{2}{c|}{16.12.2010}
&\multicolumn{2}{c|}{17.12.2010}&\multicolumn{2}{c|}{18.12.2010}
&\multicolumn{2}{c|}{19.12.2010} &\multicolumn{2}{c|}{20.12.2010}\\ \hline\hline
\endfirsthead
%
\multicolumn{18}{c}%
{{\bfseries Continued from previous page}} \\
\hline
%
No.&\multicolumn{1}{c|}{Name}& \multicolumn{2}{c|}{13.12.2010}&
\multicolumn{2}{c|}{14.12.2010}&\multicolumn{2}{c|}{15.12.2010}&
\multicolumn{2}{c|}{16.12.2010}
&\multicolumn{2}{c|}{17.12.2010}&\multicolumn{2}{c|}{18.12.2010}
&\multicolumn{2}{c|}{19.12.2010} &\multicolumn{2}{c|}{20.12.2010}\\ \hline\hline
\endhead
%
\hline \multicolumn{18}{|r|}{{Continued on next page}} \\ \hline
\endfoot
%
\hline
\multicolumn{18}{|r|}{{Concluded}} \\ \hline
\endlastfoot
%
\DTLforeach{names}{
\no=number, \dg=degree, \name=Name}{
\no& \dg. \name & & & & & & & &
& & & & & & & & \\ \hline
}
\end{longtable}%
%
\end{landscape}
%
\end{document}