Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
    
Please add a minimal working example (MWE) that illustrates your problem. (Snippets tend to be much harder to answer.) –  Joseph Wright Jul 2 '11 at 6:18
    
Sorry, next time I add –  Molurd Jul 2 '11 at 13:53

1 Answer 1

up vote 5 down vote accepted

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

share|improve this answer
    
Thanks! All the working. –  Molurd Jul 2 '11 at 13:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.