# How to replace last comma by dot after last encountered word?

My question is related but with some complication. How to replace last comma by dot after last encountered word?

% !TeX program = pdflatex
% !TeX encoding = utf8

\documentclass[]{book}
\usepackage{filecontents}
\begin{filecontents*}{data.dat}
Number|Entry
1|Alpha
2|Beta
2|Gamma
3|Delta
\end{filecontents*}

\usepackage{datatool}
\DTLsetseparator{|}

\begin{document}

\DTLforeach*[\Number=2]{letters}% database label
{\Number=Number, \Entry=Entry}% assignment
{% Stuff to do at each iteration:
\DTLiflastrow{\Entry.}{\Entry,} % Here should be a right solution
}
\end{document}

• A solution is not difficult in this particular case where at each iteration you just add \Entry. I'm afraid you can have more complicated settings, so I'm waiting for you to be more specific. Or are all applications like this and the one in your previous question? – egreg Apr 26 '19 at 14:00
• @egreg All applications like in my MWE, maybe, one possible complication, the entries can be located not only in a row but also in a column. – sergiokapone Apr 26 '19 at 17:00

The other way round:

\documentclass[]{book}
\usepackage{filecontents}
\begin{filecontents*}{data.dat}
Number|Entry
1|Alpha
2|Beta
2|Gamma
3|Delta
\end{filecontents*}

\usepackage{datatool}
\DTLsetseparator{|}