I want to combine two string columns into one column. The contents of the columns should be in two lines, i.e., first column's content must be in the first row of the combined column and second column's content must be in the second row of the combined column. I have to use multirow environment since the number of rows belonging to a ColA and ColB pair is variable. For example, it is 3 in the following sample table, table.txt.
\documentclass{article}
\usepackage{pgfplotstable}
\usepackage{multirow}
\begin{filecontents}{table.txt}
ColA ColB ColX
A C 1
A C 2
A C 3
B D 4
B D 5
B D 6
\end{filecontents}
\begin{document}
\def\numps{3}
\def\numpsMONE{2}
\pgfplotstableread{table.txt}\table
\pgfplotstabletypeset[columns={Combined, ColX}, columns/ColA/.style={string type},columns/ColB/.style={string type},create on use/Combined/.style={string type, column name={Combined}, column type=l, create col/assign/.code={
\xdef\entry{\thisrow{ColA} \thisrow{ColB}}
% I cannot put \\ between thisrow{ColA} and thisrow{ColB}
\edef\empty{}
\pgfmathparse{Mod(\pgfplotstablerow,\numps) == 0 ? 1 : 0}
\ifnum\pgfmathresult=1
% \pgfkeyslet{/pgfplots/table/create col/next content}\entry
% If I use \pgfkeyslet, A C is printed, however I cannot use multirow
\pgfkeyssetvalue{/pgfplots/table/create col/next content}{\multirow{\numpsMONE}{*}{\entry}}
% If I use \pgfkeyssetvalue,B D is printed but A C is not printed
\else
\pgfkeyslet{/pgfplots/table/create col/next content}\empty
\fi
}},columns/Combined/.style={string type},]\table
\end{document}
This code prints:
Combined ColX
1
B D 2
3
4
B D 5
6
What I need is:
Combined ColX
1
A 2
C 3
4
B 5
D 6
Thanks in advance!
