[Tex/LaTex] adding row numbers to a pgfplotstable


I've had a look at the attached answer Automatic table row numbers but I'm not sure how to apply it to pgfplotstable. I'd like to get automatic rownumbers on my table so I can apply formatting by row index. (for subtotals and the like).

I have over 100 rows so its hard to scan visually and know the row number, and the columns aren't named so something like

\pgfplotstableset{create on use/new/.style={create col/set={\thisrow{columns={0}}}}}

followed by a


doesnt work and gives me an error. Is there an easy way to get automatic row numbers in a pgfplotstable?

Best Answer

You could use the key every first column to display the counter value at the start of column 1:

enter image description here


  • As you can see, I don't have much experience with pgfplotstable, hence the bad formatting. Will come back and fix the columns later.



    Column A, Column B, Column C
       99, 98, 96
       88, 87, 84

\pgfplotstableread[col sep=comma]{sample.csv}\MySampleData


    every first column/.style={column type/.add={>{\makebox[3em][l]{\arabic{MyCount}\stepcounter{MyCount}~}}}{} }

Related Question