I would like to write small tex files containing values with an external program and then show the result in my main tex file using \input in an siunitx S column.
Lets assume a file named pi_file.tex with the content 3.141592654 exists in the current folder.
The minimal (non-working) example is as follows:
\documentclass{article}
\usepackage{siunitx}
\usepackage{xcolor}
\begin{document}
\begin{table} \centering
\caption{Table with \texttt{S} column type.}
\begin{tabular}{cS}
\hline
Symbol & {Value} \\
\hline
$\pi$ & \input{pi_file.tex} \\
Red $\pi$ & \color{red} 6.283185307 \\
\hline
\end{tabular}
\end{table}
\end{document}
I think, the macro expansion for \input takes place later than the work needed for siunitx S column formatting.
How can I still use my external file pi_file.tex with siunitx S columns?
The result should of course look like this:

Based on a comment, I managed to load a value in the table, but I am not able to make it a new command which takes the filename as an argument:
\documentclass{article}
\usepackage{siunitx}
\usepackage{xcolor}
\def\inputval{0}
\newread\inputFile
\openin\inputFile=pi_file.tex
\read\inputFile to \inputval
\closein\inputFile
\begin{document}
\begin{table} \centering
\caption{Table with \texttt{S} column type.}
\begin{tabular}{cS}
\hline
Symbol & {Value} \\
\hline
$\pi$ & \inputval \\
Red $\pi$ & \color{red} 283186.12 \\
\hline
\end{tabular}
\end{table}
\end{document}



\defit works without siunitx S columns but not with the S columns anymore. The example I gave in the edit of course is not very practical. – Lukas Oct 24 '17 at 16:41