# Centering the first row of a table in CSV reader

I am creating tables from a csv file by using "csvsimple" package. The contents of the tables are all left aligned, hence I would like to know whether it possible to center the first row alone (and the remaining rows aligned to the left) ?

My code is:

\documentclass{beamer}
\usepackage{csvsimple}

\begin{filecontents*}{\jobname.csv}
0.1,0.4,0.7,1.0,1.3
0.201,1.001,1.801,4.601,3.401
0.200,1.000,1.800,2.600,3.400
\end{filecontents*}

\begin{document}

\begin{frame}

%full filter=\ifcsvstrcmp{\csvcoliv}{m}{\csvfilteraccept}{\csvfilterreject}
]{\jobname.csv}{}{\csvlinetotablerow}%

\end{frame}

\end{document}


Csvsimple \csvautotabular and \csvautobooktabular with centered columns' content shows how to switch the default alignment to center for the entire table, but can this be done only for the first row?

• Great. I've added the link to the question with egreg's answer, because that might help somebody trying to answer this one and it is easier if it is in the post rather than the comments. If I've misunderstood or you don't like it, feel free to roll back the edit. (I also changed 'raw' to 'row', which I think is what you meant.) – cfr Sep 14 '17 at 15:32
• @CFR, your edits made the question clearer. Thank you very much for spending your valuable time on this. – Ashok Sep 14 '17 at 16:37

It is possible with \csviffirstrow, adding \multicolumn{1}{c|}{...} for every element of the first row.

The trick of the fake first column @{}p{0pt}@{} is necessary to avoid a ! Misplaced \omit error.

\documentclass{beamer}
\usepackage{csvsimple}

\begin{filecontents*}{\jobname.csv}
0.1,0.4,0.7,1.0,1.3
0.201,1.001,1.801,4.601,3.401
0.200,1.000,1.800,2.600,3.400
\end{filecontents*}

\begin{document}

\begin{frame}
\begin{tabular}{@{}p{0pt}@{}|*5{l|}}
\hline