Off the cuff Heiko Oberdiek's package catchfile comes to my mind.
You can use macros of this package for defining macros from the content of a file.
I can offer a routine
\CatchFilesForScantokens{⟨comma-separated file list⟩}{⟨preamble code⟩}{⟨postamble code⟩}
which reads and collects the ⟨preamble code⟩ and the content of each file of the ⟨comma-separated file list⟩ and the ⟨postamble code⟩ in verbatim-catcode-regime and then passes collected/accumulated things to \scantokens so that normal catcode-régime is in effect when the verbatimized material gets re-tokenized.
You can use this routine as
\CatchFilesForScantokens{⟨comma-separated file list⟩}%
{⟨stuff for initiating spreadtab-environment}%
{⟨stuff for ending the spreadtab-environment⟩}
(Internally with each file of the ⟨comma-separated file list⟩ the routine uses the \CatchFileDef-macro of the package catchfile for (re)defining a scratch-macro A from the content of that file, tokenized in verbatim-catcode/category-12-régime, and then appends the expansion of that scratch-macro A to the definition of another scratch-macro B. ⟨preamble code⟩ and ⟨postamble code⟩ also go to that other scratch-macro B. Thus everything is accumulated in that other scratch-macro B whose expansion can be passed to \scantokens for re-tokenization under normal catcode-régime.
I am lazy, so I use expl3's function \clist_map_inline:nn for parsing the ⟨comma-separated file list⟩).
Here is the example:
% Create 15 MyBu<X>.txt-files
% ==========================
\begin{filecontents*}{MyBu1.txt}
[0,-1]+1&@BU1& @513& 270.00& 551.30& 3231.30\\
\end{filecontents*}
\begin{filecontents*}{MyBu2.txt}
[0,-1]+1&@BU2& @513& 270.00& 551.30& 3231.30\\
\end{filecontents*}
\begin{filecontents*}{MyBu3.txt}
[0,-1]+1&@BU3& @513& 270.00& 551.30& 3231.30\\
\end{filecontents*}
\begin{filecontents*}{MyBu4.txt}
[0,-1]+1&@BU4& @513& 270.00& 551.30& 3231.30\\
\end{filecontents*}
\begin{filecontents*}{MyBu5.txt}
[0,-1]+1&@BU5& @513& 270.00& 551.30& 3231.30\\
\end{filecontents*}
\begin{filecontents*}{MyBu6.txt}
[0,-1]+1&@BU6& @513& 270.00& 551.30& 3231.30\\
\end{filecontents*}
\begin{filecontents*}{MyBu7.txt}
[0,-1]+1&@BU7& @513& 270.00& 551.30& 3231.30\\
\end{filecontents*}
\begin{filecontents*}{MyBu8.txt}
[0,-1]+1&@BU8& @513& 270.00& 551.30& 3231.30\\
\end{filecontents*}
\begin{filecontents*}{MyBu9.txt}
[0,-1]+1&@BU9& @513& 270.00& 551.30& 3231.30\\
\end{filecontents*}
\begin{filecontents*}{MyBu10.txt}
[0,-1]+1&@BU10& @513& 270.00& 551.30& 3231.30\\
\end{filecontents*}
\begin{filecontents*}{MyBu11.txt}
[0,-1]+1&@BU11& @513& 270.00& 551.30& 3231.30\\
\end{filecontents*}
\begin{filecontents*}{MyBu12.txt}
[0,-1]+1&@BU12& @513& 270.00& 551.30& 3231.30\\
\end{filecontents*}
\begin{filecontents*}{MyBu13.txt}
[0,-1]+1&@BU13& @513& 270.00& 551.30& 3231.30\\
\end{filecontents*}
\begin{filecontents*}{MyBu14.txt}
[0,-1]+1&@BU14& @513& 270.00& 551.30& 3231.30\\
\end{filecontents*}
\begin{filecontents*}{MyBu15.txt}
[0,-1]+1&@BU15& @513& 270.00& 551.30& 3231.30\\
\end{filecontents*}
% ==========================================================================================
% Define macro
%
% \CatchFilesForScantokens{<comma-separated file list>}{<preamble code>}{<postamble code>}
%
% to read and collect <preamble-code> and each file of <comma-separated file list> and
% <postamble code> in verbatim-catcode-regime and to pass collected things to \scantokens:
% ==========================================================================================
\RequirePackage{catchfile}
\newcommand\MyScratchmacroA{}%
\newcommand\MyScratchmacroB{}%
% Within a local scope temporarily change the catcode-régime:
\begingroup
%
\makeatletter
\ExplSyntaxOn
%
% We won't need \makeatother / \ExplSyntaxOff as -- like the other changes to the
% catcode-régime -- the effects of \makeatletter and \ExplSyntaxOn will be gone
% when the local scope is closed by @firstofone.
%
% Use the SOH(=Start Of Heading)-character, code-point-number 1 in ASCII, accessible
% as ^^A in TeX's ^^-notation, for commenting:
\catcode\^^A=14 % % Make the CR(=Carriage-Return)-character, code-point-number 13 in ASCII, accessible % as ^^M in TeX's ^^-notation, an ordinary character --- every line must end by something % that is taken for a comment-character by TeX as long as this setting is in effect : \catcode^^M=12\relax%
% Make % an ordinary character:
\catcode\%=12\relax^^A ^^A \@firstofone{^^A ^^A the first thing \@firstofone shall do is close the local scope where the ^^A catcode-régime is changed: \endgroup^^A ^^A============================================================================= ^^A PARAPHERNALIA: ^^A \UD@firstoftwo, \UD@secondoftwo, \UD@stopromannumeral, \UD@CheckWhetherNull, ^^A============================================================================= \newcommand\UD@firstoftwo[2]{#1}^^A \newcommand\UD@secondoftwo[2]{#2}^^A \@ifdefinable\UD@stopromannumeral{\chardef\UD@stopromannumeral=^^00}^^A
^^A-----------------------------------------------------------------------------
^^A Check whether argument is empty:
^^A.............................................................................
^^A \UD@CheckWhetherNull{<Argument which is to be checked>}%
^^A {<Tokens to be delivered in case that argument
^^A which is to be checked is empty>}%
^^A {<Tokens to be delivered in case that argument
^^A which is to be checked is not empty>}%
^^A
^^A The gist of this macro comes from Robert R. Schneck's \ifempty-macro:
^^A <https://groups.google.com/forum/#!original/comp.text.tex/kuOEIQIrElc/lUg37FmhA74J>
\newcommand\UD@CheckWhetherNull[1]{^^A
\romannumeral\expandafter\UD@secondoftwo\string{\expandafter^^A
\UD@secondoftwo\expandafter{\expandafter{\string#1}\expandafter^^A
\UD@secondoftwo\string}\expandafter\UD@firstoftwo\expandafter{\expandafter^^A
\UD@secondoftwo\string}\expandafter\UD@stopromannumeral\UD@secondoftwo}{^^A
\expandafter\UD@stopromannumeral\UD@firstoftwo}^^A
}^^A
^^A-----------------------------------------------------------------------------
^^A Check whether_verbatimized_ argument has a trailing explicit
^^A <carriage-return>-character-token of catcode 12(other):
^^A-----------------------------------------------------------------------------
^^A \UD@CheckWhetherTrailingCarriageReturn{<Argument which is to be checked>}%
^^A {<Tokens to be delivered in case
^^A <argument which is to be checked>'s
^^A last token is an explicit <carriage-
^^A return>-character-token of
^^A catcode 12(other)>}%
^^A {<Tokens to be delivered in case
^^A <argument which is to be checked>'s
^^A last token is not an explicit
^^A <carriage-return>-character-token of
^^A catcode 12(other)>}%
\newcommand\UD@CheckWhetherTrailingCarriageReturn[1]{^^A
\UD@@CheckWhetherTrailingCarriageReturn#1\UD@SelDom^^M\UD@SelDom\UD@@SelDom^^A
}^^A
@ifdefinable\UD@@CheckWhetherTrailingCarriageReturn{^^A
\long\def\UD@@CheckWhetherTrailingCarriageReturn#1^^M\UD@SelDom#2\UD@@SelDom{^^A
\UD@CheckWhetherNull{#2}{\UD@secondoftwo}{\UD@firstoftwo}^^A
}^^A
}^^A
^^A=============================================================================
\NewDocumentCommand\CatchFilesForScantokens{m}{^^A
\begingroup^^A
\let\do@makeother^^A
\do^^I^^A
\CatchFilesForScantokensInner{#1}^^A
}^^A
\newcommand\verbatimregime{^^A
\let\do@makeother^^A
\dospecials^^A
\do^^I^^A
\do^^M^^A
\endlinechar=`^^M\relax^^A
\newlinechar=\endlinechar^^A
}^^A
\NewDocumentCommand\CatchFilesForScantokensInner{m+v+v}{^^A
\endgroup^^A
\begingroup^^A
\edef\MyScratchmacroB{^^A
\expandafter\UD@CheckWhetherTrailingCarriageReturn\expandafter{\detokenize{#2}}^^A
{\unexpanded\expandafter{\detokenize{#2}}}^^A
{\unexpanded\expandafter{\detokenize{#2^^M}}}^^A
}^^A
\clist_map_inline:nn{#1}{^^A
^^A\message{##1^^J}^^A
\CatchFileDef{\MyScratchmacroA}{##1}{\verbatimregime}^^A
\edef\MyScratchmacroB{^^A
\unexpanded\expandafter\expandafter\expandafter{\expandafter\MyScratchmacroB\detokenize\expandafter{\MyScratchmacroA}}^^A
}^^A
}^^A
\edef\MyScratchmacroB{^^A
\unexpanded\expandafter\expandafter\expandafter{\expandafter\MyScratchmacroB\detokenize{#3}%}^^A
}^^A
\newlinechar=\endlinechar^^A
^^A=======================================================================
^^A If you want to see on connsole what \scantokens gets as spreadtab,
^^A then enable the next but one line by removing the leading ^^A
^^A=======================================================================
^^A\show\MyScratchmacroB^^A
\scantokens\expandafter{\expandafter\endgroup\MyScratchmacroB}^^A
}^^A
}%
% Create document:
% =================
\documentclass{article}
\usepackage[a4paper,left=2.5cm,right=2.5cm,bottom=2.8cm,top=2.8cm]{geometry}
\usepackage{longtable,tabu}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage{datetime}
\usepackage{siunitx}
\usepackage{multirow}
\usepackage[sc]{mathpazo}
\usepackage{datatool}
\usepackage{spreadtab,booktabs,xpatch}
\usepackage[]{numprint}
\usepackage[]{eurosym}
\usepackage{fp}
\usepackage{booktabs}
\usepackage{tabularx,siunitx}
\usepackage{numprint}
\begin{document}
\CatchFilesForScantokens{%
MyBu1.txt,
MyBu2.txt,
MyBu3.txt,
MyBu4.txt,
MyBu5.txt,
MyBu6.txt,
MyBu7.txt,
MyBu8.txt,
MyBu9.txt,
MyBu10.txt,
MyBu11.txt,
MyBu12.txt,
MyBu13.txt,
MyBu14.txt,
MyBu15.txt
}%
{%
\begin{spreadtab}{{tabular}{@{\hskip1pt }r@{\hskip7pt }p{2.7cm }crrr}}
\toprule
&@ Ku& @ Re & @ Ne & @ Me & @ Br \ % <- This is row 1.
\midrule
\SThiderow 0&&&&&\ % <- This is row 2 and it is invisible and used for initial values.
}%
{%
\midrule
&@To & [-2,-1] &(sum(d3:[0,-1]))tag(BN) & sum(e3:[0,-1])tag(BM)& sum(f3:[0,-1])tag(BB)\
\bottomrule
\end{spreadtab}
}%
\end{document}

!!! This approach is based on reading/tokenizing files in verbatim-category-code-régime. Hereby \input-commands occurring within some of the files of the ⟨comma-separated file list⟩ will not be carried out. I.e., \input-nesting is not possible. All you can do is provide a list of files. !!!
!!! Also it is relied on reading and tokenizing the ⟨preamble code⟩ and the ⟨postamble code⟩ in verbatim-category-code-régime. This in turn implies that \CatchFilesForScantokens
- cannot be hidden inside the definition of whatsoever macro and
- cannot be used inside macro-arguments, i.e.,
- must be used in ways where it is ensured that the arguments will be obtained by reading and tokenizing things from the .tex-input-file while the changes of the category-code-régime temporarily introduced by
\CatchFilesForScantokens are in effect.
!!!
\inputas long as they are not nested. Do you really need more than 15 nested\input? – Phelype Oleinik Oct 27 '21 at 13:35\inputs, as long as they are not nested. With nested I mean a filea.texthat does\input{b.tex}that does\input{c.tex}that does\input{d.tex}that does... If you change that toa.texthat does\input{b.tex}\input{c.tex}\input{d.tex}... it will work fine – Phelype Oleinik Oct 27 '21 at 13:40\inputcommands remain where they are. – Phelype Oleinik Oct 27 '21 at 13:47.txtfiles (you could just include the same.txt15 times). Note: for something like this I'd probably use an external template engine to generate the table or what ever this is instead of using many inputs – daleif Oct 27 '21 at 13:59\everyeof{\spreadtab@iv\noexpand}% \expandafter\spreadtab@iv\@@input#2is forcing every input file to execute input again at the end so it will loop forever and you will run out of input levels however many you allow. What do you intend this to do? – David Carlisle Oct 27 '21 at 14:04--max-in-open=nwhen calling latex/pdflatex/xelatex/lualatex from the command-line. TeXLive: My system contains the file/usr/local/texlive/2020/texmf-dist/web2c/texmf.cnfwhere settings are done. That file, however, says that modifications that shall not be lost when updating should go to/usr/local/texlive/2020/texmf.cnf. So to/usr/local/texlive/2020/texmf.cnfyou could addmax_in_open = 30 % simultaneous input files and error insertions, also applies to MetaPost. But... – Ulrich Diez Oct 27 '21 at 15:30\input/\@@inputuntil capacities are exceeded. – Ulrich Diez Oct 27 '21 at 15:31\inputindividual rows and then have TeX create the summary row? – Teepeemm Nov 02 '21 at 01:01