I am new on this forum and have a question about transposing data with the pgfplotstable package. I have found a post explaining how to transpose a table and have tried to make modifications using the documentation but I am not managing to find the right commands.

I have an input CSV file which contains a series of values (one line only):

2016-06-13 05:00,6.2,5305,849,29.0,160,1,160

I want to use LaTeX

  1. to read the file,
  2. generate a vertical table with the values, and
  3. assign an arbitrary name for each line of the output table.

The code I have for this:



    col sep=comma,

%    header=false
    input colnames to={colA,colB}

string type,
every head row/.style={before row=\toprule, after row=\midrule},
every last row/.style={after row=\bottomrule},
every col no 0/.style={
    column type={l},
    column name={Averages for the week},
    %postproc cell content/.append style={/pgfplots/table/@cell content/.add={Subj }{}},


With this code, I get a table with only one column (and some text appended at the end of the last row "index7"), whereas I would like to have something like this (where I define in the TEX file names for each rows:

wanted output

Is it possible to do this?

Thank you very much in advance for your replies.

  • Welcome to TeX.SX!! Nice question. Rather than posting code fragments it is better to post a full minimal working example. A MWE should start with a \documentclass command, have a minimal preamble and then \begin{document}...\end{document}. The code should compile and be as small as possible to demonstrate your problem. This makes it much easier for people to help you --- and much more likely that they will! – Andrew Aug 8 '16 at 10:40

Maybe something like this:

2016-06-13 05:00,6.2,5305,849,29.0,160,1,160
Averages for the week starting & \Week\\
\Longstack[l]{Row Name1,
Row Name2,
Row Name3,
Row Name4,
Row Name5,
Row Name6,
Row Name7} & 

enter image description here


It is possible using \pgfplotstable, just very very difficult.

2016-06-13 05:00,6.2,5305,849,29.0,160,1,160

\pgfplotstableread[col sep=comma,header=false,string type]{
Averages for week starting,RowName1,RowName2,RowName3,RowName4,RowName5,RowName6,RowName7
}\names% create column names
\fbox{\pgfplotstabletypeset[string type]\names}% debug

    col sep=comma,
    string type
\fbox{\pgfplotstabletypeset[string type]\normal}% debug

\let\mydate=\pgfplotsretval% will become column name later
\mydate% debug

\fbox{\pgfplotstabletypeset[string type,]\names}% debug

\pgfplotstabletranspose[header=false,colnames from=0]\transpose\names
\fbox{\pgfplotstabletypeset[string type]\transpose}% debug

\pgfplotstabletypeset[string type,columns={Averages for week starting,\mydate},
  columns/Averages for week starting/.style={column type=l},
  columns/\mydate/.style={column type=r},



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.