I have a word count command in Latex that works well, based on the code here. However, I want the output number to be comma separated for thousands (e.g., 1,000 instead of 1000). I have tried using \numprint and \siunitx but they give me errors, presumably because they can only be applied to a number and not a command. Here is my code:
\documentclass{article}
\usepackage{verbatim}
\usepackage{lipsum}
\newcommand{\quickwordcount}[1]{%
\immediate\write18{texcount -0 -sum -merge -q #1.tex > #1-words.sum}%
\input{#1-words.sum}%
}
\begin{document}
There are \quickwordcount{main}words in this document.
\end{document}
Of course, in this example there are only 6 words, but I didn't want to add 1,000 words just to show that it says "1000". How can I show the output with comma separators for thousands?

\usepackage{siunitx}and then\num[group-separator={,}]{12345}, which gives "12,345". But\num[group-separator={,}]{\quickwordcount{main}}gives an error. – Marco Pastor Mayo Jun 16 '23 at 15:53