5

I'm writing some lua code that outputs a table saved to a file that is then read by \pgfplotstableread{myfile.dat}\mytable. I'd like to avoid two steps: saving to a file and reading with \pgfplotstableread. So, my option is to "write" directly \mytable on lua side. But I don't know how tables are stored internally by pgfplotstable. I did some experiment:

\documentclass{article}
\usepackage{pgfplotstable}

\pgfplotstableread[col sep=comma]{
Name, Age, stDev
Adam, 15, 3
Eve, 12, 1
}\mytable

\begin{document}

\show\mytable

\end{document}

This results in:

> \mytable=macro:
->\pgfpl@@ {Name}\pgfpl@@ {Age}\pgfpl@@ {stDev}.

So I guess the other lines are stored in other macros. My question is how?

1
  • Check out \pgfplotstablegetelem{⟨row⟩}{⟨col⟩}\of⟨table⟩. – Symbol 1 Oct 14 '16 at 17:20
2

According to the comments in pgfplotstableshared.code.tex (line 31-53)

% This file provides a high-level table manipulation and typesetting
% package.
%
%
% ---------------------------------------------
%  Implementation notes for programmers:
% ---------------------------------------------
%
%  The table data structure consists of
%  1. A name which must be a valid TeX macro like '\table'
%  2. A column list in the \pgfplotslist format.
%   In fact, the column list is stored in the table's name:
%     \pgfplotslistnewempty\table
%  3. A "file name" stored in
%     \csname\string<\namemacro>@@table@name\endcsname
%  4. A "scan line length" number stored in
%         \csname\string<\namemacro>@@table@scanline\endcsname
%         It contains the value of \pgfplotsscanlinelength which has
%         been identified right after \pgfplotstableread.
%  5. foreach column, there is a list of row-values (a row-vector) in
%  the \pgfplotslist format named
%         \csname\string<\namemacro>@<column name>\endcsname
%

we can write the following test

\documentclass{article}
\usepackage{pgfplotstable}
\pgfplotstableread[col sep=comma]{
Name, Age, stDev
Adam, 15, 3
Eve, 12, 1
}\mytable

\begin{document}
\begin{itemize}\makeatletter\ttfamily

\item[2] \string\mytable \\
\meaning\mytable

\item[3] file name \\
\expandafter\meaning\csname\string\mytable @@table@name\endcsname

\item[4] scan line length \\
\expandafter\meaning\csname\string\mytable @@table@scanline\endcsname

\item[5] column Name \\
\expandafter\meaning\csname\string\mytable @Name\endcsname

\item[5] column Age \\
\expandafter\meaning\csname\string\mytable @Age\endcsname

\item[5] column stDev \\
\expandafter\meaning\csname\string\mytable @stDev\endcsname

\end{itemize}
\end{document}

This gives us

0

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.