1
\documentclass{article}
\usepackage{caption}
\usepackage{booktabs}
\usepackage{csvsimple}

\csvstyle{mystyle}{
    tabular=|c|c|c|,
    table head=\hline Gruppe & Buchstabe & Zahl \\ \hline,
    table foot=\bottomrule,
    no head,
    late after line=\\ \hline,
    late after first line=\\\midrule,
}

\title{Title}

\newcommand{\csvfilename}{BSP_Gruppenaufteilung_Loop.csv} %Name CSV. Datei
\begin{document}
\begin{table}[htb]
\centering
\caption{Table with columns 1, 3, and 4\label{tab134}}
\csvreader[mystyle, separator=semicolon]{\csvfilename}{}{
\ifcsvstrcmp{\csvcoli}{Gruppe 1}
    {
        \csvcoli & \csvcoliii & \csvcoliv
    }{}
}
\end{table}



\begin{table}[htb]
\centering
\caption{Table with columns 1, 3, and 4\label{tab134}}
\csvreader[mystyle, separator=semicolon]{\csvfilename}{}{
\ifcsvstrcmp{\csvcoli}{Gruppe 2}
    {
        \csvcoli & \csvcoliii & \csvcoliv
    }{}
}
\end{table}
\end{document}

I have presorted csv file and created multiple tables sorted by Group.

After Compiling this is the result:

I would like that each table or group will start on the top of each table and that there no empty spaces in between. I also would like the the /hline and || lines only show for not empty cells.

Thanks in advance for your help!

Best regards Roman

0

1 Answer 1

0
  1. The test \ifcsvstrcmp{... doesn't select rows, it just suppresses the text of the row giving you an empty row, as you have noticed. The proper way to select rows is with a filter.
  2. With booktabs you should put \toprule before and \midrule after the header, and \bottomrule after the table, without \hline after the last row.
  3. With booktabs it is recommended to not use vertical lines. I have left them, but it isn't pretty. I leave it to you to decide.
\documentclass{article}
\usepackage{caption}
\usepackage{booktabs}
\usepackage{csvsimple}

\csvstyle{mystyle}{
    tabular=|c|c|c|,
    table head=\toprule Gruppe & Buchstabe & Zahl \\ \midrule,
    table foot=\bottomrule,
    no head,
    late after line=\\ \hline,
    late after last line=\\,
}

\title{Title}

\newcommand{\csvfilename}{BSP_Gruppenaufteilung_Loop.csv} %Name CSV. Datei
\begin{document}
\begin{table}[htb]
\centering
\caption{Table with columns 1, 3, and 4\label{tab134}}

\csvreader[mystyle, separator=semicolon,
           filter equal={\csvcoli}{Gruppe 1}]{\csvfilename}{}
           {\csvcoli & \csvcoliii & \csvcoliv}
\end{table}



\begin{table}[htb]
\centering
\caption{Table with columns 1, 3, and 4\label{tab135}}
\csvreader[mystyle, separator=semicolon,
           filter equal={\csvcoli}{Gruppe 2}]{\csvfilename}{}
        {\csvcoli & \csvcoliii & \csvcoliv}
\end{table}
\end{document}

enter image description here

1
  • Thank you so much!!!!
    – Roman
    Commented Jun 3 at 8:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .