I am using csvreader from the csvsimple package to generate a table in my document. I am struggling to get a top border on the table. Here is the code, including writing the .csv
\documentclass{article}
\usepackage{csvsimple}
% Make csv in question
\begin{filecontents*}{scientists2.csv}
name,surname,
Albert,Einstein,
Marie,Curie,
Thomas,Edison
\end{filecontents*}
\begin{document}
\begin{center}
\csvreader[tabular=|l|l|,
table head=\textbf{ First Name} & \textbf{Last Nmae} \\\hline,
late after line = \\\hline]%
{scientists2.csv}{name=\name,surname=\surname}%
{\name & \surname}%
\end{center}
\end{document}
What argument can I pass (to tabular?) to see the top border? I am using TexWorks to compile. Thanks,
Best Answer
1.
csvsimple
:You can simply adjust the
table head
to start with an\hline
:2.
booktabs
:However, the
booktabs
package is usually recommened to produce more professional looking tables. So, I have added a second example that uses this along with thedatatool
package:Much thanks to Nicola Talbot, who helped with proper use of
booktabs
here.3.
pgfplotstable
:A solution using
pgfplotstable
is provided at Bold one cell in table using CSV reader.Notes:
Not sure why I needed the extra
\\
before the\bottomrule
which is producing the additional spacing at the bottom. To fix this I added a manual\vspace*{-12pt}
, which is more of a hack.It appears the the
csvsimple
package was discarding the last row as it did not have a trailing,
.Code: