4

How can I get from this dataA.dat

a b c 
1 2 3 
4 5 6 
7 8 9 

and this dataB.dat

A    B    C
1.1  2.1  3.1
4.1  5.1  6.1
7.1  8.1  9.1

(as shown in the MWE) to this:

a   b   c
1   2   3
4   5   6
7   8   9

1.1 2.1 3.1
4.1 5.1 6.1
7.1 8.1 9.1

where should be one blank line between the two data-blocks in the PDF-result.

%\documentclass[paper=a5]{scrartcl}
\documentclass[varwidth, border=2pt]{standalone}
\usepackage{pgfplotstable}
\usepackage{filecontents}
\begin{document}

\begin{filecontents}{dataA.dat}
a b c
1 2 3
4 5 6
7 8 9
\end{filecontents}

\begin{filecontents}{dataB.dat}
1.1 2.1 3.1
4.1 5.1 6.1
7.1 8.1 9.1
\end{filecontents}

\pgfplotstableread{dataA.dat}\dataA
\pgfplotstableread{dataB.dat}\dataB

\pgfplotstablecreatecol[copy column from table={\dataB}{[index] 0}] {A} {\dataA}
\pgfplotstablecreatecol[copy column from table={\dataB}{[index] 1}] {B} {\dataA}
\pgfplotstablecreatecol[copy column from table={\dataB}{[index] 2}] {C} {\dataA}

\pgfplotstabletypeset[precision=4]{\dataA}
\end{document}
  • For numerical input empty rows would trip an error. Do you need the blank row for typesetting? – percusse Jan 20 '16 at 16:33
  • Yes, the result table will be somithing like that ` 5 0 * * * 5 1 * * * 5 2 * * * ... 5 4 * * * <linebreak !!!> 10 0 * * * 10 1 * * * 10 2 * * * ... – cis Jan 20 '16 at 17:10
  • Sry, unable to make linebreaks here... – cis Jan 20 '16 at 17:11
3

You can include the empty line in the \pgfplotstabletypeset and combine the tables with \pgfplotstablevertcat. The vertical concatenation requires the col names to be the same so I reordered them. Kind of ugly but if needed it can be embedded to a generic style to ease the overwriting.

\documentclass{article}
\usepackage{pgfplotstable}

\pgfplotstableread{
a b c A   B   C
1 2 3 1.1 2.1 3.1
4 5 6 4.1 5.1 6.1
7 8 9 7.1 8.1 9.1
}\mytable

\pgfplotstableset{
create on use/a/.style={copy column from table={\mytable}{[index] 0}},
create on use/b/.style={copy column from table={\mytable}{[index] 1}},
create on use/c/.style={copy column from table={\mytable}{[index] 2}},
}

\pgfplotstablenew[columns={a,b,c}]{3}{\dataA}

\pgfplotstableset{
create on use/a/.style={copy column from table={\mytable}{[index] 3}},
create on use/b/.style={copy column from table={\mytable}{[index] 4}},
create on use/c/.style={copy column from table={\mytable}{[index] 5}},
}
\pgfplotstablenew[columns={a,b,c}]{3}{\dataB}


\pgfplotstablevertcat{\dataA}{\dataB}

\begin{document}

\pgfplotstabletypeset[every row no 2/.append style={after row={&&\\ }}]{\dataA}};

\end{document}

enter image description here

  • Ok, but this is to times the table from dataA(?) – cis Jan 20 '16 at 19:15
  • 1
    @cis facepalm... I'll fix asap – percusse Jan 20 '16 at 21:09
  • OK............ ;) – cis Jan 21 '16 at 23:54
  • 1
    @cis Sorry for the delay. Done – percusse Jan 22 '16 at 21:59

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.