# Pgfplotstable. How to exclude one row from sorting scope?

I am a beginner in LaTeX, experimenting with industrial documents. I cannot find the suitable code to solve some of the problems below:

1. I would like to be able to sort the table, but excluding the final row, supposed to be a summary.
2. I could not find how to apply the fixed, zerofill, dec sep align, precision=2 parameters to all columns but the first.
3. I could not make the code for bold fonts in the last row to work.
\documentclass{article}
\usepackage{colortbl,hhline}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\usepackage{filecontents}
\usepackage{booktabs}

\begin{filecontents}{data.csv}
{Items},{Rating},{Design 1},{Design 2},{Design 3}
Design complexity, 6.3,3.5, 8.5, 8.12
Cost,9.2, 3.8, 5.77, 5.9
Energy consumption,6.62,4.8, 8.1,9.5
Average weighted normalized,, 3.7, 7.92,7.35
\end{filecontents}

\begin{document}

\centering
\pgfplotstabletypeset[font=\small,
every even row/.style={
before row={\rowcolor[gray]{0.9}}},
before row=\toprule,after row=\midrule},
every last row/.style={
after row=\bottomrule},
%every first column/.style={string type},%does not work
columns/Items/.style={string type}, %works
column 2/.style={fixed, zerofill, dec sep align, precision=2}, %does not work
every last column/.style={fixed, zerofill, dec sep align, precision=1},
%sort, sort key={Design 2}, %Works but should not include last row
%sort cmp={float >}, %Works but should not include last row
every first column/.style={column type={l}}, %Does not work
before row={\toprule},
after row=\midrule
},
every last row/.style={before row={\bottomrule},
after row={\bottomrule},
postproc cell content/.style={@cell content=\textbf{##1}}}, %does not work
]{\datatable}

\end{document}

-

1. The task to sort all except for one can be done by means of a temporary column in which the sort weight of the "special" row has an extreme value.
2. column styles need to be applied to individual columns. You can either assign styles by column name or by (output) column index. In your case, you may want to create a shared style numeric column which is referenced by all others.
3. This is a usability issue of pgfplotstable; see also PGFplotstable: Is it possible to set a number format for a *row* instead of a column?

Here is your modified example. I added %% CF wherever I modified stuff. I also addressed your "does not work" markers:

\documentclass{article}
\usepackage{colortbl,hhline}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\usepackage{filecontents} \usepackage{booktabs}

\begin{filecontents}{data.csv}
{Items},{Rating},{Design 1},{Design 2},{Design 3}
Design complexity, 6.3,3.5, 8.5, 8.12
Cost,9.2, 3.8, 5.77, 5.9
Energy consumption,6.62,4.8, 8.1,9.5
Average weighted normalized,, 3.7, 7.92,7.35
\end{filecontents}

\begin{document}

\centering
\pgfplotstabletypeset[
% CF:
numeric column/.style={fixed, zerofill, dec sep align, precision=2},
display columns/1/.style={numeric column},
display columns/2/.style={numeric column},
display columns/3/.style={numeric column},
display columns/4/.style={numeric column},
display columns/5/.style={numeric column},
display columns/6/.style={numeric column},
%%%
font=\small,
every even row/.style={
before row={\rowcolor[gray]{0.9}}},
before row=\toprule,after row=\midrule},
every last row/.style={
after row=\bottomrule},
%every first column/.style={string type},%does not work
%% CF: yes, it does: but you overwrite it a couple of lines below
%%
columns/Items/.style={string type}, %works
column 2/.style={fixed, zerofill, dec sep align, precision=2}, %does not work
%% CF: this is the wrong style  'display columns/2/.style='
%%
every last column/.style={fixed, zerofill, dec sep align, precision=1},
%sort, sort key={Design 2}, %Works but should not include last row
%sort cmp={float >}, %Works but should not include last row
%% CF:
sort, sort key={sort key},
sort cmp={float >},
create on use/sort key/.style={
create col/assign/.code={
\begingroup
\global\edef\entry{\thisrow{Design 2}}
\count0=\pgfplotstablerow
\ifnum\count0=\pgfplotstablerows
\global\def\entry{-1e20}%
\fi
\endgroup
%\message{sort key entry no \pgfplotstablerow / \pgfplotstablerows: \entry^^J}%
\pgfkeyslet{/pgfplots/table/create col/next content}\entry
},
},
every first column/.style={column type={l}}, %Does not work
%% CF: see above
before row={\toprule},
after row=\midrule
},
every last row/.style={before row={\bottomrule},
after row={\bottomrule},
postproc cell content/.style={@cell content=\textbf{##1}}}, %does not work
%% CF: confirmed... the style every last row does not support this.
%% Sorry; not properly documented or reported.
]{\datatable}

\end{document}


The create on use/sort key declaration defines how to create the sort key column which is referenced in the value of sort key. I used a temporary integer register to add "+1" to the row index, compared that with the number of rows and assigned some special extreme value for the last row. It is awkward due to TeX's ugly programming language...

@Ives I'm glad the answer proved to be useful. Thanks for the greetings :) Was a good time. Concerning the every first column: it worked for me (except that you declare it twice which essentially overwrites the first declaration). And it is evaluated in the very same place as columns/Items/.style, i.e. there should be no difference. –  Christian Feuersänger Aug 4 '12 at 9:41