# csvreader longtable caption repeated on every page

I am using csvreader with longtable and I added a caption in table head below is my code:

\csvreader[
longtable=ccc,
table head=\caption{Caption goes here.
}\label{tab:sometab} \\
\toprule\bfseries id &\bfseries gene &\bfseries name \\ \midrule\endhead
\bottomrule\endfoot,
late after line=\\,
]{app/fsnewtax.csv}{1=\id,2=\gene,3=\name}{\id&\gene&\name}


This is part of the csv file:

23271,cox3,Poec
685,cox3,Pier
5,atp6,Luc
85,atp6,Mut


The problem is: the caption is repeated on every page of the table, I want it to be just on the first page. How to do this ? I couldn't find anything related to adding caption in the csvsimple documentation.

Your problem is very simple to solve, just use \endfirsthead after what you want on the first page and \endhead after what you want on the following pages. See longtable package documentation.

I repeated your data many times in the fsnewtax.csv of my MWE to have a table two page long.

Moreover, I put the label inside the caption description without going to a new line, otherwise the caption is not correctly centered.

\begin{filecontents*}{fsnewtax.csv}
23271,cox3,Poec
685,cox3,Pier
5,atp6,Luc
85,atp6,Mut
23271,cox3,Poec
685,cox3,Pier
5,atp6,Luc
85,atp6,Mut
23271,cox3,Poec
685,cox3,Pier
5,atp6,Luc
85,atp6,Mut
23271,cox3,Poec
685,cox3,Pier
5,atp6,Luc
85,atp6,Mut
23271,cox3,Poec
685,cox3,Pier
5,atp6,Luc
85,atp6,Mut
23271,cox3,Poec
685,cox3,Pier
5,atp6,Luc
85,atp6,Mut
23271,cox3,Poec
685,cox3,Pier
5,atp6,Luc
85,atp6,Mut
23271,cox3,Poec
685,cox3,Pier
5,atp6,Luc
85,atp6,Mut
23271,cox3,Poec
685,cox3,Pier
5,atp6,Luc
85,atp6,Mut
\end{filecontents*}
\documentclass{article}
\usepackage{csvsimple}
\usepackage{longtable}
\usepackage{booktabs}
\begin{document}