I have a simple two-lines csv file, which I've imported to latex with csvsimple like this:

\begin{filecontents*}{data.csv}
1,2,3,4,5
101,102,104,105,106
-1,-2,-3,-4,-5
\end{filecontents*}
...
\begin{table}
\begin{tabular}{*{5}{c}}
\end{tabular}
\end{table}


But I want to add a header on the left side of the table and I've been seeing no way to do it.

In other words I want something like this:

How does that can be accomplish?

• You cannot add it to your csv file? – Benjamin Feb 23 '16 at 18:27
• Is that acceptable practice? Latex compiler marks any math insertion in csv file as parse error. – Rasmussen Feb 23 '16 at 18:37
• I just tried it with $I_c$ and $U_\mathrm{same}$ and had no problem. – Benjamin Feb 23 '16 at 18:40

For a two-line csv file, you can differentiate between the lines using \csviffirstrow. Simply put the two headers into the settings for the first and the following line(s):

\documentclass[12pt]{article}

\usepackage{csvsimple}

\begin{filecontents*}{data.csv}
1,2,3,4,5
101,102,104,105,106
-1,-2,-3,-4,-5
\end{filecontents*}

\begin{document}

\begin{table}
\csvloop{
file=data.csv,
tabular=|*{6}{c|},
command=\csviffirstrow{$I_c$}{$U_\mathrm{same}$} & \csvlinetotablerow,

• Suppose all data on csv has the format 0.000000. Is it possible to format the table entry with only 2 decimal places? I mean, like 0.00, automatically. – Sigur Feb 13 '18 at 18:22
• @Sigur Yes, this is possible. For example, formatting with help of the siunitx package can be done. You find an application example in Section 5.4 (page 36) of the csvsimple documentation. – Thomas F. Sturm Feb 14 '18 at 11:38