[Tex/LaTex] Simple table with csvsimple, with no headers

csvcsvsimple

I am not managing to make a simple table in csvsimple.

My data is like this:
value 1, 5.5
value 2, 3806.0
value 3, 601.0
value 4, 26.8
value 5, 150.0
value 6, 2.0
value 8, 75.0
value 9, 21

I have made the following code and I cannot figure out what is the problem:

\documentclass{article}
\usepackage{csvsimple}

\begin{document}
\csvreader[tabular==|l|r|,
no head,
table head=\hline,
late after line=\\\hline
]{data.csv}
\end{document}

Any advice would be greatly appreciated !

Thanks,
Kind regards,

Nicolas

Best Answer

[EDIT Some how I missed @Gernot's comment. This answer is nothing more than an expanded version of what he wrote.]

I think that you have two problems.

  1. A typo: tabular==|l|r| should be tabular=|l|r|.
  2. There are missing arguments to the \csvreader command that are supposed to say how the table should be constructed.

From your question it is not entirely clear to me what data.csv looks like so I have used the file:

5.5
3806.0
601.0
26.8
150.0
2.0
75.0
21

Changing your MWE to

\documentclass{article}
\usepackage{csvsimple}

\begin{document}
  \csvreader[tabular=|l|r|,
  no head,
  table head=\hline,
  late after line=\\\hline]{data.csv}{}{\thecsvrow & \csvcoli}%
\end{document}

you now obtain the table:

enter image description here

Note that \thecsvrow gives the row number and, for a given row, \csvcoli gives the entry in column 1. There are also \csvcolii, \csvcoliii and so on. So the argument {\thecsvrow & \csvcoli} to \csvreader says that each of the table show start with the row index and then have the corresponding entry in column 1 of the data file.

Finally, I'd recommend reading the manual from the booktabs package as it explains why you shouldn't use vertical rules in tables:)