After fiddling for a while, I came up with a solution (not using a \loop
-\repeat
-solution):
\documentclass{article}
\usepackage{csvsimple,array,filecontents,booktabs}
\usepackage{forloop}
\newcount\loopcount
\loopcount=5
\newcounter{loopiti}
\def\continuefortheglory{%
&\fortheglory%
}
\def\fortheglory{%
\stepcounter{loopiti}%
\myhead{%
\expandafter\csname csvcol\roman{loopiti}\endcsname%
}%
\ifnum\loopcount>\value{loopiti}%
\expandafter\continuefortheglory%
\fi%
}
\begin{filecontents*}{forum_posts_table_1.csv}
posts per author,sentences per post,quoted sentences per post,EREs per post,mentions per ERE
3.1,23.83454,2313.27,13453453.8,2464642.43
4.1,23.83454,2313.27,13453453.8,2464642.43
5.1,23.83454,2313.27,13453453.8,2464642.43
\end{filecontents*}
\begin{document}
\newcommand\myhead[1]{\parbox[t]{5em}{\centering\bfseries#1\par\kern1mm}}
\csvreader[no head,column count=5,tabular=rrrrr,
table head=\toprule,
late after first line=\\\midrule,
table foot=\bottomrule
]%
{forum_posts_table_1.csv}{}{%
\csviffirstrow{\myhead{\csvcoli} & \myhead{\csvcolii} & \myhead{\csvcoliii}
& \myhead{\csvcoliv} & \myhead{\csvcolv}
}{\csvlinetotablerow}
}
\vskip5mm
using fortheglory:
\vskip5mm
\setcounter{loopiti}{0}
\csvreader[no head,column count=5,tabular=rrrrr,
table head=\toprule,
late after first line=\\\midrule,
table foot=\bottomrule
]%
{forum_posts_table_1.csv}{}{%
\csviffirstrow{\fortheglory}{\csvlinetotablerow}
}
\end{document}

EDIT: With this you have to use \loopcount=
for every table, that doesn't have the same number of columns as the previous one and have to issue \setcounter{loopiti}{0}
before every table, but you could include this in a wrapper command like this:
\newcommand{\glorycol}[1]{\loopcount=#1\setcounter{loopiti}{0}\fortheglory}
Then you just have to use it for a table with, e.g. 5 columns, like this:
\csvreader[no head,column count=5,tabular=rrrrr,
table head=\toprule,
late after first line=\\\midrule,
table foot=\bottomrule
]%
{forum_posts_table_1.csv}{}{%
\csviffirstrow{\glorycol{5}}{\csvlinetotablerow}
}
There might be a better way (for example automaticly determining the number of columns and giving an optional argument just if that fails) but that's out of my skill (at the moment, I hope...).
\loop
and\repeat
. Just set an if-statement in front of the\repeat
:\loop\StuffToBeDone\ifagain\repeat
with\StuffToBeDone
the stuff you want to be done in each repetition and\ifagain
an if-statement which evaluates to false if the loop should end.