7

How can I make table in pgfplotstable table form input file

A  B
1.0 20
1.1 21
1.2 22
1.3 23
1.4 24

looks like this one: enter image description here

I trying to use \pgfplotstabletranspose\loadedtable{input.dat} \pgfplotstabletypeset\loadedtable, but column names (A & B) parsing as floats (and gives error). And colnames counting starts from 0 (I need from 1).

And also is it posible to break (hyphenate) large horizontal tables?

5

The error for the A and B column comes from the fact that pgfplotstables expects numerical data unless specified otherwise. To make the column handle strings, you have to set columns/colnames/.style={string type}.

To get the index to start at one, I would suggest to create a new column on the fly and using this for the column names with the key colnames from=<name>.

Here's an MWE:

\documentclass{article}

\usepackage{pgfplotstable}
\usepackage{filecontents}

\begin{filecontents}{testdata.dat}
A  B
1.0 20
1.1 21
1.2 22
1.3 23
1.4 24
\end{filecontents}

\begin{document}

\pgfplotstableset{
    create on use/index/.style={%
        create col/assign/.code={%
            \pgfmathtruncatemacro\entry{\pgfplotstablerow+1}%
            \pgfkeyslet{/pgfplots/table/create col/next content}{\entry}
        }
    }
}

\pgfplotstabletranspose[colnames from=index]\loadedtable{testdata.dat} 

\pgfplotstabletypeset[
    columns/colnames/.style={
        string type,
        column name={\#}
    }
]\loadedtable

\end{document}

pgfplotstabletranspose

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.