0

I get a Code from @egreg that create rows in outwritten textfiles in a loop.
I need to put all these rows together in 1 pgfplotstable, that means something like

\ifnum\the\filecount=1 \pgfplotstableread[col sep=comma]{data\the\filecount.txt}{\main}\else 
\pgfplotstableread[col sep=comma]{data\the\filecount.txt}{\temp}
% \pgfplotstablevertcat{\main}{\temp}  % <--- Does not work!

How do I have to place the pgfplotstablevertcat-command?

Note that for my main algorithm, I have to charge contents of the preceding rows in subsequent rows. I would therefore leave it for the first time in this elaborate output method. The later main code may be discussed and simplified later.

enter image description here

\documentclass[a4paper]{article}
\usepackage{pgfplotstable}

\newcount\filecount
\newwrite\cisout
\begin{document}

\filecount=1
\def\aaa{file number \the\filecount}%
\loop
\immediate\openout\cisout=data\the\filecount.txt
\immediate\write\cisout{%
111, 222,   \aaa
}
\immediate\closeout\cisout
\ifnum\the\filecount=1 \pgfplotstableread[col sep=comma]{data\the\filecount.txt}{\main}\else 
\pgfplotstableread[col sep=comma]{data\the\filecount.txt}{\temp}
% \pgfplotstablevertcat{\main}{\temp}  % <--- Does not work!
\fi
\advance\filecount by 1
\ifnum\filecount<5
\repeat

\section{The Main Table is incomplete}
\pgfplotstabletypeset[col sep=comma, string type]{\main}

\section{The last Temp-Table}
\pgfplotstabletypeset[col sep=comma, string type]{\temp}

\section{Input Test}
\input{data1.txt} \\
\input{data2.txt}\\
\input{data3.txt}\\
\input{data4.txt}
\end{document}
0

It works alike this way:

\documentclass[a4paper]{article}
\usepackage{pgfplotstable}

\pgfplotstableset{string type}

\newcount\filecount
\newwrite\cisout
\begin{document}

\filecount=1
\def\aaa{\the\filecount}%
\loop
\immediate\openout\cisout=data\the\filecount.txt
\immediate\write\cisout{%
111, 222,  \aaa
}
\immediate\closeout\cisout
\ifnum\the\filecount=1 \pgfplotstableread[col sep=comma, string type]{data\the\filecount.txt}{\main}%
\else \pgfplotstableread[col sep=comma, string type]{data\the\filecount.txt}{\temp}%
\pgfplotstablevertcat{\main}{\temp}% <--- Does  work!
\fi%
\advance\filecount by 1
\ifnum\filecount<5
\repeat

\section{The Main Table is incomplete}
\pgfplotstabletypeset[col sep=comma, string type]{\main}

\section{The last Temp-Table}
\pgfplotstabletypeset[col sep=comma, string type]{\temp}

\section{Input Test}
\input{data1.txt} \\
\input{data2.txt}\\
\input{data3.txt}\\
\input{data4.txt}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.