Automatic table creation from a list

I want to build a table form a list (using pgffor package):

\newcommand{\tablecontent}{
\foreach \theproduct in \productlist {
\getproductcount{\theproduct} &
\getproductdescr{\theproduct} &
\getproductprice{\theproduct}\\\hline
}
}


And then use it to create a table like this:

\begin{tabularx}{\textwidth}{c|c|c}
.... \\% title row
\tablecontent
.... \\% total row
\end{tabularx}


But I have the following error: Extra }, or forgotten \endgroup.

• This can't work this way, because \foreach can't operate beyond table cells' which form a TeX group – user31729 Sep 5 '17 at 14:57
• Hi, welcome. There have been several questions here on the site about using loops to create tables before, if you search a bit perhaps you can find something useful. – Torbjørn T. Sep 5 '17 at 15:30
• If you have is .csv list, you can make a table with csvsimple or datatool packages. – Bernard Sep 5 '17 at 15:35

I found a solution to my problem, by using another loop iterator form xintootls. Note that \xintFor doesn't allow usage of \edef, but works in tabular environment.
\usepackage{xinttools}
`