Latex Table from Csv File

The following code for creating Latex table from csv file is missing horizontal line on top of the table.

\documentclass{article}
\usepackage{csvsimple} 

% Make csv in question
\begin{filecontents*}{check.csv}
labels,names,A,C,V,tools
a,example,838,663,683,
b,otter,353,215,192,
d,\textbf{broccoli},79,79,117,
e,fibredensityandcrosssection,1086,849,868,
ad,hcp-prefree:exec-centos7.freebuild-centos4-latest,70,76,157,
ar,shots47s\_fmriprep-1.2.3,,,,453
\end{filecontents*}

\begin{table*}[!ht]
\csvreader[%
 tabular={|c|c|c|c|c|c|},
        table head = \textbf{Labels} &\textbf{{names}} & \textbf{A} & \textbf{C} & \textbf{V} & \textbf{T}\\\hline,
        late after line= \\,
        late after last line=\\\hline %
        ]{check.csv}{labels=\labels,names=\names,A=\A,C=\C,V=\V,tools=\tools}%
        {\labels & \names & \A & \C & \V & \tools}
       \centering
        \caption{\label{table1}Number by category}
\end{table*}
 
\end{document}

How we can add top horizontal line on top of table?

1 Answer

Please note that building such a data prison is bad style. Have a look at , or for some guides about nice looking tables.

 \documentclass{article}
 \usepackage{csvsimple} 

 % Make csv in question
\begin{filecontents*}{check.csv}
labels,names,A,C,V,tools
a,example,838,663,683,
b,otter,353,215,192,
d,\textbf{broccoli},79,79,117,
e,fibredensityandcrosssection,1086,849,868,
ad,hcp-prefree:exec-centos7.freebuild-centos4-latest,70,76,157,
ar,shots47s\_fmriprep-1.2.3,,,,453
\end{filecontents*}
\begin{document}
\begin{table*}[!ht]
\csvreader[%
 tabular={|c|c|c|c|c|c|},
        table head = \hline\textbf{Labels} &\textbf{{names}} & \textbf{A} & \textbf{C} & \textbf{V} & \textbf{T}\\\hline,
        late after line= \\,
        late after last line=\\\hline %
        ]{check.csv}{labels=\labels,names=\names,A=\A,C=\C,V=\V,tools=\tools}%
        {\labels & \names & \A & \C & \V & \tools}
       \centering
        \caption{\label{table1}Number by category}
\end{table*}
 
 \end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Robert Thorne

Robert Thorne

Automotive & Future Transportation Editor

Robert Thorne covers electric vehicle innovations, autonomous driving systems, global mobility trends, and automotive engineering developments.

Share this article
Twitter Facebook Pinterest