# Problem retrieving text from pgf plot table

I'm trying to include and fetch text from a pgf plot table without succeeding.

When using just numbers, everything goes smoothly:

\documentclass{standalone}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\usepackage{tikz}

1
}\mydata

\begin{document}
\begin{tikzpicture}
\pgfplotstablegetelem{0}{0}\of\mydata
\node[draw=black] at (0,0) {\pgfplotsretval};
\end{tikzpicture}

\end{document}


However, when exchanging the number for a letter or a text string, like so

\documentclass{standalone}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\usepackage{tikz}

a
}\mydata

\begin{document}
\begin{tikzpicture}
\pgfplotstablegetelem{0}{0}\of\mydata
\node[draw=black] at (0,0) {\pgfplotsretval};
\end{tikzpicture}

\end{document}


I get the following error message:

! Package pgfplots Error: Sorry, could not retrieve column '0' from table '<inl
ine_table>'. Please check spelling (or introduce name aliases)..

See the pgfplots package documentation for explanation.
Type  H <return>  for immediate help.
...

l.12 \pgfplotstablegetelem{0}{0}\of\mydata


How can I include and fetch text from my pgf plot table? I've tried things like enclosing the text in " or ' to no avail.

-

If \pgfplotstableread encounters a non-numeric character in the first line of the table, it assumes that this line contains the column names. In this case, it thinks that your table contains just one column, called a, without any data, which is why trying to retrieve the first element of column 0 doesn't work: There's no column called 0, and there's no first element. You can tell PGFPlots that everything should be treated as data by setting header=false in the \pgfplotstableread options:

\documentclass{standalone}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\usepackage{tikz}

a
}\mydata

\begin{document}
\begin{tikzpicture}
\pgfplotstablegetelem{0}{0}\of\mydata
\node[draw=black] at (0,0) {\pgfplotsretval};
\end{tikzpicture}

\end{document}

-
Excellent! My real problem was trying to fetch data from a larger file, where the first row first contained some text strings and then a bunch of numbers. I guess this means that numbers aren't allowed as column names. –  Speldosa Jan 11 '13 at 10:54
@Speldosa: Glad it helps! Numbers are allowed as column names: In that case, you have to set header=has colnames. –  Jake Jan 11 '13 at 11:07