I have data set as follows:
id vala valb
1 24 75
2 56 87
In this data set, there are two value types: vala
and valb
. The number of types may change, it can be three, four, etc.
I need to convert this first data set to:
id val type
1 24 a
1 75 b
2 56 a
2 87 b
and then typeset it. Or without conversion, typeset the first data set in the format of the second data set.
type
column is to differentiate id
s, however it is not very necessary. If possible, it should be generated from the last character of the column names.
Here is MWE:
\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm]{geometry}
\usepackage{pgfplotstable}
\pgfplotsset{width=10cm,compat=1.6}
\usepackage{filecontents}
\begin{filecontents}{testdataExisting.dat}
id vala valb
1 24 75
2 56 87
\end{filecontents}
\begin{filecontents}{testdataGenerated.dat}
id val type
1 24 a
1 75 b
2 56 a
2 87 b
\end{filecontents}
\begin{document}
Table 1
\pgfplotstabletypeset[col sep=space,columns={id,vala,valb},]{testdataExisting.dat}
Table 2
\pgfplotstabletypeset[col sep=space,columns={id,val,type},
columns/type/.style={string type,column type=r},
]{testdataGenerated.dat}
\end{document}
Output: