# pgfplotstable - How can I stack the columns from a data file under one another without the headings but with additional vspace?

I'd like to typeset data in multiple columns below one another. The problem is, if I were to typeset lots of data for relatively few parameters, I'd like to typeset the content on a upright a4 page. In consequence I'd like to stack the columns in the back under the columns in the front. One could use several \pgfplotstypeset commands of course but then, what about the alignment and precise formatting? So this question is about trying to typeset it with one command, if possible. I am sure some of you may find this trivial but I have never used pgfplotstable before so I am a bit baffled.

Specifically I supplied some fake data file data.txt which I would like to typeset in a table with 7 columns.

The typeset table shall have 1 head row. It should have a first column which I want to fill with content myself (which would be AA, BB, CC,... in every fifth row). Then the columns Word--ColHeadAA5 should follow. The content up to this point should be put up top. The data in the remaining columns ColHead1BB-ColHead5BB should be put below that. The columns which get put below shall not include their column headings, only the data. They should of course be put in the columns 3--7, not the first two columns.

It is noteworthy that this is of course an abstract example--one might expand this to plenty more columns "converted" into stacked "rows". I also intend to implement some booktabs formatting if I'll use this.

Is this even possible?

Little extra: between the stacked sets I'd like to have some additional vertical space inserted, something that roughly equals \addlinespace[3pt] of the booktabs-package.

## MWE

\documentclass{scrartcl}

\usepackage{pgfplotstable}

\begin{filecontents}{data.txt}
A,17,19,15,17,3,8,14,7,8,14
B,10,8,11,15,10,8,6,13,13,10
C,20,5,16,12,8,5,16,7,14,17
D,14,4,10,14,16,14,5,10,5,11
\end{filecontents}

\begin{document}
\begin{center}
\pgfplotstabletypeset[columns/Word/.style={string type}]{\mydata}
\end{center}
\end{document}

• Either you will need to create a new table which is actually organized the way you want it printed, or you need to extract the contents of the table and create a tabular. – John Kormylo Oct 6 '14 at 14:28
• @JohnKormylo Actually chose to typeset the table by hand. Will leave this question open though. – henry Oct 6 '14 at 19:26

It's not difficult with \pgfplotstablesave to create to parts of the original table and \pgfplotstablevertcat to vertically concatenate those two parts.

You'll find the details in the comments of my code:

\documentclass{scrartcl}
\usepackage{siunitx}
\usepackage{booktabs}
\usepackage{pgfplotstable}
\pgfplotstableset{
% create aliases for correct merging
% create first column with AA, BB, etc.
create on use/Something/.style={
create col/set list={AA,,,,BB,,,,}},
columns/Something/.style={string type}
}

\begin{filecontents}{data.txt}
A,17,19,15,17,3,8,14,7,8,14
B,10,8,11,15,10,8,6,13,13,10
C,20,5,16,12,8,5,16,7,14,17
D,14,4,10,14,16,14,5,10,5,11
\end{filecontents}

\begin{document}
col sep=comma,
]{data.txt}{\tableall}

% create table A with the fist 5 columns (and Word)
\pgfplotstablesave[
]{\tableall}{tableA.out}

% create table B with the last 5 columns (and Word)
\pgfplotstablesave[
]{\tableall}{tableB.out}

% load table A in a new table tablevertcat

% append the contents of table B to table A (tablevertcat)
\pgfplotstablevertcat{\tablevertcat}{tableB.out}

% and this is the final result
\begin{center}
\pgfplotstabletypeset[
% add a little space every 4 rows
% booktabs rules
before row=\toprule,
after row=\midrule
},
every last row/.style={
after row=\bottomrule
},
columns/Word/.style={string type},
% correct column numbers alignment
multicolumn names,