gtvawe gtvawe - 1 year ago 116
LaTeX Question

Include CSV file with more than four columns with csvsimple in Latex document by using MikTex

I am using MikTex and want to include CSV tables in my Tex document. I am using the package csvsimple. The following code works fine to include a CSV file with one to three columns.

\csvreader[separator=semicolon,late after line=\\\midrule,late after last line=\\\bottomrule]{myfile.csv}{}{\csvcoli & \csvcolii & \csvcoliii}


But now I have one more CSV file with four columns.

So I thought I can use:

\csvreader[separator=semicolon,late after line=\\\midrule,late after last line=\\\bottomrule]{myfile.csv}{}{\csvcoli & \csvcolii & \csvcoliii & \csvcoliiii}


But it doesn't work. Error message:
Undefined control sequence.
How must I edit the code snippet to include CSV tables with more than three columns?

Thank you.

Answer Source

You can access the entire row of your csv (all columns together) using \csvlinetotablerow:

\csvreader[separator=semicolon,late after line=\\\midrule,late after last line=\\\bottomrule]{myfile.csv}{}{\csvlinetotablerow}