# Is there an easy way to change the column order of a pgfplotstable?

I am aware of Rearrange data in pgfplotstable but I was hoping for a kind of one-pass solution that doesn't spread the table over so many commands but is rather self-contained within \pgfplotstabletypeset.

So here is my not-so-minimal example (sorry but I wanted to keep the thing plausible but readable ...):

\documentclass{standalone}
\usepackage{pgfplotstable}
\usepackage{booktabs}
\usepackage{colortbl}
\usepackage{ragged2e}
\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}
\newcolumntype{R}[1]{>{\RaggedLeft\arraybackslash}m{#1}}
\begin{document}
\pgfplotstabletypeset[
col sep=comma,
column type={C{.24\linewidth}},
columns/Text/.style={reset styles,string type,column type={R{.5\linewidth}}},
columns/Number/.style={reset styles,string type,column type={C{.1\linewidth}}},
/pgf/number format/fixed,
/pgf/number format/precision=2,
]{
Number,Text,Value
1,Lorem ipsum dolor sit amet,0.94178749278214
3,sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat,0.65253718698821
4,sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,0.18096270994776
5,no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet,0.29164374147955
7,sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat,0.60941476968239
8,sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren,0.12296095617755
9,no sea takimata sanctus est Lorem ipsum dolor sit amet.,0.70795563336377
}
\end{document}


Obviously I screwed up here and need to move the Number column after the Text column, so from [1, 2, 3] to [2, 1, 3]. What's the easiest way of doing that without reading the whole thing as a CSV file into a spreadsheet and then performing column-based operations there?

-

Column ordering can be altered via columns={column2,column1,...} key.

\documentclass[border=5mm]{standalone}
\usepackage{pgfplotstable}
\usepackage{booktabs}
\usepackage{colortbl}
\usepackage{ragged2e}
\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}
\newcolumntype{R}[1]{>{\RaggedLeft\arraybackslash}m{#1}}
\begin{document}
\pgfplotstabletypeset[
columns={Text,Number,Value},
col sep=comma,
column type={C{.24\linewidth}},
columns/Text/.style={reset styles,string type,column type={R{.5\linewidth}}},
columns/Number/.style={reset styles,string type,column type={C{.1\linewidth}}},
/pgf/number format/fixed,
/pgf/number format/precision=2,
]{
Number,Text,Value
1,Lorem ipsum dolor sit amet,0.94178749278214