summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2007-07-26 18:05:45 +0000
committerKarl Berry <karl@freefriends.org>2007-07-26 18:05:45 +0000
commiteb5be484f99eaae05ca8b88b93c5a4b5faa981e8 (patch)
tree86c3e9ddce78d9659f83c0df75c526b3d66fa979 /Master/texmf-dist/tex
parent34a326e46adad2fe384f8f9527ab304a7df9aba0 (diff)
csvtools update (24jul07)
git-svn-id: svn://tug.org/texlive/trunk@4657 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r--Master/texmf-dist/tex/latex/csvtools/csvpie.sty207
-rw-r--r--Master/texmf-dist/tex/latex/csvtools/csvsort.sty322
2 files changed, 529 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/csvtools/csvpie.sty b/Master/texmf-dist/tex/latex/csvtools/csvpie.sty
new file mode 100644
index 00000000000..ef2da7e00ea
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/csvtools/csvpie.sty
@@ -0,0 +1,207 @@
+%%
+%% This is file `csvpie.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% csvtools.dtx (with options: `csvpie.sty,package')
+%% Copyright (C) 2007 Nicola Talbot, all rights reserved.
+%% If you modify this file, you must change its name first.
+%% You are NOT ALLOWED to distribute this file alone. You are NOT
+%% ALLOWED to take money for the distribution or use of either this
+%% file or a changed version, except for a nominal charge for copying
+%% etc.
+%% \CharacterTable
+%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
+%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
+%% Digits \0\1\2\3\4\5\6\7\8\9
+%% Exclamation \! Double quote \" Hash (number) \#
+%% Dollar \$ Percent \% Ampersand \&
+%% Acute accent \' Left paren \( Right paren \)
+%% Asterisk \* Plus \+ Comma \,
+%% Minus \- Point \. Solidus \/
+%% Colon \: Semicolon \; Less than \<
+%% Equals \= Greater than \> Question mark \?
+%% Commercial at \@ Left bracket \[ Backslash \\
+%% Right bracket \] Circumflex \^ Underscore \_
+%% Grave accent \` Left brace \{ Vertical bar \|
+%% Right brace \} Tilde \~}
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{csvpie}[2006/09/01 v1.0]
+\newif\ifcolorpiechart
+\colorpiecharttrue
+\DeclareOption{color}{\colorpiecharttrue}
+\DeclareOption{monochrome}{\colorpiechartfalse}
+\ProcessOptions
+\RequirePackage{csvtools}
+\RequirePackage{tikz}
+\RequirePackage{calc}
+\RequirePackage{keyval}
+\newlength\csvradius
+\newlength\csvinner
+\newlength\csvouter
+\newlength\csvcutawayoffset
+\newcounter{csvstartangle}
+\newcounter{csvendangle}
+\newcounter{csvangle}
+\newcounter{csvpietotal}
+\newcommand*{\csvpiedefaults}{radius=2cm,inner=0.25,outer=1.25,%
+cutaway={},total=100,start=0,offset=0.1}
+\newcommand{\csvpieouterlabel}{\field{1}}
+\newcommand{\csvpieinnerlabel}{\field{2}\%}
+\newcommand*{\csvpiecutaways}{}
+\newcommand*{\csvpiesegmentcol}[2]{%
+\expandafter\def\csname csvpie@segcol\romannumeral#1\endcsname{#2}}
+\newcommand*{\csvpiesegcolname}[1]{%
+\csname csvpie@segcol\romannumeral#1\endcsname}
+\ifcolorpiechart
+\csvpiesegmentcol{1}{red}
+\csvpiesegmentcol{2}{green}
+\csvpiesegmentcol{3}{blue}
+\csvpiesegmentcol{4}{yellow}
+\csvpiesegmentcol{5}{magenta}
+\csvpiesegmentcol{6}{cyan}
+\csvpiesegmentcol{7}{orange}
+\csvpiesegmentcol{8}{white}
+\else
+\csvpiesegmentcol{1}{black!15}
+\csvpiesegmentcol{2}{black!25}
+\csvpiesegmentcol{3}{black!35}
+\csvpiesegmentcol{4}{black!45}
+\csvpiesegmentcol{5}{black!55}
+\csvpiesegmentcol{6}{black!65}
+\csvpiesegmentcol{7}{black!75}
+\csvpiesegmentcol{8}{black!85}
+\fi
+\define@key{csvpie}{start}{\setcounter{csvstartangle}{#1}}
+\define@key{csvpie}{total}{\setcounter{csvpietotal}{#1}}
+\define@key{csvpie}{radius}{\setlength{\csvradius}{#1}}
+\define@key{csvpie}{inner}{\setlength{\csvinner}{#1\csvradius}}
+\define@key{csvpie}{outer}{\setlength{\csvouter}{#1\csvradius}}
+\define@key{csvpie}{offset}{\setlength{\csvcutawayoffset}{#1\csvradius}}
+\define@key{csvpie}{cutaway}{\renewcommand*{\csvpiecutaways}{#1}}
+\providecommand*{\csv@startrow}{1}
+\define@key{csvpie}{firstrow}{\renewcommand*{\csv@startrow}{#1}}
+\newcommand{\csvpiechart}{%
+\@ifstar{\def\@@pieapplyCSVfile{\applyCSVfile*}%
+\def\csv@startrow{1}%
+\@csvpiechart}{%
+\def\@@pieapplyCSVfile{\applyCSVfile}%
+\def\csv@startrow{2}%
+\@csvpiechart}%
+}
+\newcommand*{\csvpiesetkeys}[1]{%
+\edef\csv@piesk{\noexpand\setkeys{csvpie}{\csvpiedefaults,#1}}%
+\csv@piesk}
+\newcommand{\@csvpiechart}[3][]{%
+{\csvpiesetkeys{#1}%
+\edef\csv@startang{\number\c@csvstartangle}%
+\csv@computeangles{#2}{#3}%
+\setcounter{csvstartangle}{\csv@startang}%
+\begin{tikzpicture}%
+\@@pieapplyCSVfile[\csv@startrow]{#3}{%
+\csvpiesegment{#2}}%
+\end{tikzpicture}%
+}}
+\newcommand*{\csvpiesegment}[1]{%
+\setcounter{csvstartangle}{%
+\csname csv@sang@\romannumeral\c@csvrownumber\endcsname}%
+\setcounter{csvangle}{%
+\csname csv@angle@\romannumeral\c@csvrownumber\endcsname}%
+\setcounter{csvendangle}{\value{csvangle} + \value{csvstartangle}}%
+\setcounter{csvangle}{%
+\csname csv@cut@angle\romannumeral\c@csvrownumber\endcsname}%
+\ifthenelse{\value{csvangle}>180}{\addtocounter{csvangle}{-360}}{}%
+\edef\@csv@shift{(\number\c@csvangle:%
+\csname csv@cut@len\romannumeral\c@csvrownumber\endcsname)}%
+\setcounter{csvangle}{%
+\csname csv@angle@\romannumeral\c@csvrownumber\endcsname/2
++\value{csvstartangle}}%
+\begin{scope}[shift={\@csv@shift}]%
+\fill[color=\csvpiesegcolname\c@csvrownumber] (0,0) --
+(\thecsvstartangle:\csvradius)
+arc (\thecsvstartangle:\thecsvendangle:\csvradius) -- cycle;
+\ifthenelse{\(\value{csvangle}>90 \and \value{csvangle}<270\)
+\TE@or \value{csvangle}<-90}{%
+\setcounter{csvstartangle}{\value{csvangle}-180}%
+\draw (\thecsvangle:\csvinner)
+node[left,rotate=\thecsvstartangle]{\csvpieinnerlabel};
+\draw (\thecsvangle:\csvouter)
+node[left,rotate=\thecsvstartangle]{\csvpieouterlabel};
+}{%
+\draw (\thecsvangle:\csvinner)
+node[right,rotate=\thecsvangle]{\csvpieinnerlabel};
+\draw (\thecsvangle:\csvouter)
+node[right,rotate=\thecsvangle]{\csvpieouterlabel};
+}%
+\end{scope}%
+}
+\newcommand*{\csv@computeangles}[2]{%
+\@@pieapplyCSVfile[\csv@startrow]{#2}{%
+\csvsetsegmentparams{\c@csvrownumber}{#1}%
+}%
+\ifthenelse{\equal{\csvpiecutaways}{}}{}{\csvcomputeoffsets}}
+\newcommand*{\csvcomputeoffsets}{%
+\@for\csv@row:=\csvpiecutaways\do{%
+\expandafter\@csv@set@off\csv@row-\relax
+}}
+\def\@csv@set@off#1-#2\relax{%
+\ifthenelse{\equal{#2}{}}{%
+\@@csv@set@off{#1}}{%
+\@@csv@set@offr#1-#2\relax}%
+}
+\newcommand*{\@@csv@set@off}[1]{%
+\setcounter{csvangle}{%
+\csname csv@angle@\romannumeral#1\endcsname/2
++ \csname csv@sang@\romannumeral#1\endcsname}%
+\expandafter\xdef\csname csv@cut@angle\romannumeral#1\endcsname{%
+\number\c@csvangle}%
+\expandafter
+\gdef\csname csv@cut@len\romannumeral\csv@row\endcsname{%
+\csvcutawayoffset}%
+}
+\newcount\@csv@seg
+\def\@@csv@set@offr#1-#2-\relax{%
+\ifnum#1>#2\relax
+\PackageError{csvpie}{Segment ranges must go in ascending
+order}{Try #2-#1 instead of #1-#2}%
+\else
+\setcounter{csvangle}{0}%
+\@csv@seg=#1\relax
+\whiledo{\not\(\@csv@seg > #2\)}{%
+\addtocounter{csvangle}{%
+\csname csv@angle@\romannumeral\@csv@seg\endcsname}%
+\advance\@csv@seg by 1}%
+\setcounter{csvangle}{\value{csvangle}/2
++ \csname csv@sang@\romannumeral#1\endcsname}%
+\@csv@seg=#1\relax
+\whiledo{\not\(\@csv@seg > #2\)}{%
+\expandafter\xdef\csname csv@cut@angle\romannumeral\@csv@seg\endcsname{%
+\number\c@csvangle}%
+\expandafter
+\gdef\csname csv@cut@len\romannumeral\@csv@seg\endcsname{%
+\csvcutawayoffset}%
+\advance\@csv@seg by 1}%
+\fi
+}
+\newcommand*{\csvsetsegmentparams}[2]{%
+\ifthenelse{\value{csvstartangle}>180}{%
+\addtocounter{csvstartangle}{-360}}{}%
+\ifthenelse{\value{csvstartangle}<-180}{%
+\addtocounter{csvstartangle}{360}}{}%
+\expandafter
+\xdef\csname csv@sang@\romannumeral#1\endcsname{%
+\number\c@csvstartangle}%
+\setcounter{csvangle}{360*\real{#2}/\value{csvpietotal}}%
+\addtocounter{csvstartangle}{\value{csvangle}}%
+\expandafter
+\xdef\csname csv@angle@\romannumeral#1\endcsname{%
+\number\c@csvangle}%
+\expandafter
+\gdef\csname csv@cut@angle\romannumeral#1\endcsname{0}%
+\expandafter
+\gdef\csname csv@cut@len\romannumeral#1\endcsname{0cm}%
+}
+\endinput
+%%
+%% End of file `csvpie.sty'.
diff --git a/Master/texmf-dist/tex/latex/csvtools/csvsort.sty b/Master/texmf-dist/tex/latex/csvtools/csvsort.sty
new file mode 100644
index 00000000000..4dad7d27e20
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/csvtools/csvsort.sty
@@ -0,0 +1,322 @@
+%%
+%% This is file `csvsort.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% csvtools.dtx (with options: `csvsort.sty,package')
+%% Copyright (C) 2007 Nicola Talbot, all rights reserved.
+%% If you modify this file, you must change its name first.
+%% You are NOT ALLOWED to distribute this file alone. You are NOT
+%% ALLOWED to take money for the distribution or use of either this
+%% file or a changed version, except for a nominal charge for copying
+%% etc.
+%% \CharacterTable
+%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
+%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
+%% Digits \0\1\2\3\4\5\6\7\8\9
+%% Exclamation \! Double quote \" Hash (number) \#
+%% Dollar \$ Percent \% Ampersand \&
+%% Acute accent \' Left paren \( Right paren \)
+%% Asterisk \* Plus \+ Comma \,
+%% Minus \- Point \. Solidus \/
+%% Colon \: Semicolon \; Less than \<
+%% Equals \= Greater than \> Question mark \?
+%% Commercial at \@ Left bracket \[ Backslash \\
+%% Right bracket \] Circumflex \^ Underscore \_
+%% Grave accent \` Left brace \{ Vertical bar \|
+%% Right brace \} Tilde \~}
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{csvsort}[2007/07/03 v1.0 (NLCT)]
+\@ifundefined{compare}{\input{compare}}{}
+\newif\if@csv@ishigher
+\newcommand{\csv@alphaascendingcompare}[2]{%
+\@csv@extractkey#1{\@csv@keya}%
+\@csv@extractkey#2{\@csv@keyb}%
+\csvsort@verbose{Comparing \@csv@keya\space and \@csv@keyb}%
+\edef\@csvsrt@result{\noexpand\compare{\@csv@keya}{\@csv@keyb}}%
+\ifnum\@csvsrt@result=1\relax
+ \@csv@ishighertrue
+\else
+ \@csv@ishigherfalse
+\fi}
+\newcommand{\csv@alphadescendingcompare}[2]{%
+\@csv@extractkey#1{\@csv@keya}%
+\@csv@extractkey#2{\@csv@keyb}%
+\csvsort@verbose{Comparing \@csv@keya\space and \@csv@keyb}%
+\edef\@csvsrt@result{\noexpand\compare{\@csv@keya}{\@csv@keyb}}%
+\ifnum\@csvsrt@result=-1\relax
+ \@csv@ishighertrue
+\else
+ \@csv@ishigherfalse
+\fi}
+\newcommand{\csv@numericascendingcompare}[2]{%
+\@csv@extractkey#1{\@csv@keya}%
+\@csv@extractkey#2{\@csv@keyb}%
+\if\relax\@csv@keya\relax\def\@csv@keya{0}\fi
+\if\relax\@csv@keyb\relax\def\@csv@keyb{0}\fi
+\csvsort@verbose{Comparing \number\@csv@keya\space and \number\@csv@keyb}%
+\ifnum\@csv@keya>\@csv@keyb\relax
+ \@csv@ishighertrue
+\else
+ \@csv@ishigherfalse
+\fi}
+\newcommand{\csv@numericdescendingcompare}[2]{%
+\@csv@extractkey#1{\@csv@keya}%
+\@csv@extractkey#2{\@csv@keyb}%
+\if\relax\@csv@keya\relax\def\@csv@keya{0}\fi
+\if\relax\@csv@keyb\relax\def\@csv@keyb{0}\fi
+\csvsort@verbose{Comparing \number\@csv@keya\space and \number\@csv@keyb}%
+\ifnum\@csv@keya<\@csv@keyb\relax
+ \@csv@ishighertrue
+\else
+ \@csv@ishigherfalse
+\fi}
+\def\@csv@extractkey#1#2#3{\def#3{#1}}
+\def\@csv@extractdata#1#2#3{\def#3{#2}}
+\let\csv@compare\csv@alphaascendingcompare
+\RequirePackage{xkeyval}
+\define@boolkey{csvsort.sty}[csvsrt]{verbose}[true]{}
+\csvsrtverbosetrue
+\newcommand{\csvsort@verbose}[1]{%
+\ifcsvsrtverbose\typeout{#1}\fi}
+\define@choicekey{csvsort.sty}{sort}[\val\nr]{alphabetical,numerical,%
+alphabetical ascending,numerical ascending,%
+alphabetical descending,numerical descending,%
+alphabeticalascending,alphabeticaldescending,%
+numericalascending,numericaldescending}{%
+\ifcase\nr
+ % alphabetical (ascending)
+ \let\csv@compare\csv@alphaascendingcompare
+ \or
+ % numerical (ascending)
+ \let\csv@compare\csv@numericascendingcompare
+ \or
+ % alphabetical ascending
+ \let\csv@compare\csv@alphaascendingcompare
+ \or
+ % numerical ascending
+ \let\csv@compare\csv@numericascendingcompare
+ \or
+ % alphabetical descending
+ \let\csv@compare\csv@alphadescendingcompare
+ \or
+ % numerical descending
+ \let\csv@compare\csv@numericdescendingcompare
+ \or
+ % alphabeticalascending
+ \let\csv@compare\csv@alphaascendingcompare
+ \or
+ % alphabetical descending
+ \let\csv@compare\csv@alphadescendingcompare
+ \or
+ % numericalascending
+ \let\csv@compare\csv@numericascendingcompare
+ \or
+ % numericaldescending
+ \let\csv@compare\csv@numericdescendingcompare
+\fi}
+\newcommand{\csv@sortvariable}{\field{1}}
+\define@key{csvsort.sty}{variable}{%
+\renewcommand{\csv@sortvariable}{#1}}
+\newcounter{sfirstdataline}
+\setcounter{sfirstdataline}{1}
+\define@key{csvsort.sty}{sfirstdataline}{%
+\setcounter{sfirstdataline}{#1}}
+\newcounter{firstdataline}
+\setcounter{firstdataline}{2}
+\define@key{csvsort.sty}{firstdataline}{%
+\setcounter{firstdataline}{#1}}
+\ProcessOptionsX
+\RequirePackage{csvtools}
+\RequirePackage{xfor}
+\newcommand{\csv@insertionsort}[1]{%
+\let\@csv@sortedlist\relax
+\@for\@csv@listelement:=#1\do{%
+\if\@csv@sortedlist\relax
+ \expandafter\toks@\expandafter{\@csv@listelement}%
+ \edef\@csv@sortedlist{\the\toks@}%
+\else
+ \expandafter\@csv@insert@into\expandafter
+ {\@csv@listelement}{\@csv@sortedlist}%
+\fi}\let#1\@csv@sortedlist}
+\newcommand\@csv@insert@into[2]{%
+\let\@csv@tmplist\relax
+\@for\@sort@list@element:=#2\do{%
+ \expandafter\csv@compare\expandafter{\@sort@list@element}{#1}%
+ \if@csv@ishigher
+ \toks@{#1}%
+ \if\relax\@csv@tmplist
+ \edef\@csv@tmplist{\the\toks@,\@sort@list@element}%
+ \else
+ \edef\@csv@tmplist{\@csv@tmplist,\the\toks@,\@sort@list@element}%
+ \fi
+ \@endfortrue
+ \else
+ \if\relax\@csv@tmplist
+ \edef\@csv@tmplist{\@sort@list@element}%
+ \else
+ \edef\@csv@tmplist{\@csv@tmplist,\@sort@list@element}%
+ \fi
+ \fi
+}%
+\if@endfor
+ \ifx\@forremainder\@empty
+ \else
+ \edef\@csv@tmplist{\@csv@tmplist,\@forremainder}%
+ \fi
+\else
+ \toks@{#1}%
+ \if\relax\@csv@tmplist
+ \edef\@csv@tmplist{\the\toks@}%
+ \else
+ \edef\@csv@tmplist{\@csv@tmplist,\the\toks@}%
+ \fi
+\fi
+\@endforfalse
+\let#2\@csv@tmplist
+}
+\newcommand{\sortapplyCSVfile}{%
+\@ifstar\@ssortapplyCSVfile\@sortapplyCSVfile}
+\newcommand{\@ssortapplyCSVfile}[3][]{%
+\bgroup
+\setkeys{csvsort.sty}{#1}%
+\def\@csv@list{}%
+\@sapplyCSVfile[\c@sfirstdataline]{#2}{%
+\edef\csv@key{\csv@sortvariable}%
+\if\relax\@csv@list\relax
+\protected@xdef\@csv@list{{\csv@key}{\csvline}}%
+\else
+\protected@xdef\@csv@list{\@csv@list,{\csv@key}{\csvline}}%
+\fi
+}%
+\@ssortapplyCSVdata{\@csv@list}{#3}%
+\egroup}
+\newcommand{\@sortapplyCSVfile}[3][]{%
+\bgroup
+\setkeys{csvsort.sty}{#1}%
+\def\@csv@list{}%
+\@applyCSVfile[\c@firstdataline]{#2}{%
+\edef\csv@key{\csv@sortvariable}%
+\if\relax\@csv@list\relax
+\protected@xdef\@csv@list{{\csv@key}{\csvline}}%
+\else
+\protected@xdef\@csv@list{\@csv@list,{\csv@key}{\csvline}}%
+\fi
+}%
+\@sortapplyCSVdata{\@csv@list}{#3}%
+\egroup}
+\newcommand{\sortapplyCSVdata}{%
+\@ifstar\@ssortapplyCSVdata\@sortapplyCSVdata}
+\newcommand{\@ssortapplyCSVdata}[3][\relax]{%
+\bgroup
+\if\relax#1\relax\else\setkeys{csvsort.sty}{sort=#1}\fi
+\csv@insertionsort{#2}%
+\c@csvrownumber=0\relax
+\@for\@csv@element:=#2\do{%
+\expandafter\@csv@extractdata\@csv@element\csvline
+\expandafter\toks@\expandafter{\csvline}%
+\edef\@csvlin@{\@csvseparator\the\toks@\@csvseparator}%
+\long\edef\@csvlin@{\@csvseparator\csvline\@csvseparator}%
+\c@field=0\relax
+\whiledo{\not\equal{\@csvlin@}{\@csvseparator}}{%
+\extractentry{\@csvlin@}{\param}%
+\expandafter\toks@\expandafter{\param}%
+\advance\c@field by 1\relax
+\expandafter\xdef\csname @field\romannumeral\c@field\endcsname{%
+\the\toks@}%
+}%
+\ifthenelse{\not\equal{\csvline}{}}{%
+\refstepcounter{csvrownumber}%
+#3}{}%
+}%
+\egroup
+}
+\newcommand{\@sortapplyCSVdata}[3][\relax]{%
+\bgroup
+\if\relax#1\relax\else\setkeys{csvsort.sty}{sort=#1}\fi
+\csv@insertionsort{#2}%
+\c@csvrownumber=0\relax
+\@for\@csv@element:=#2\do{%
+\expandafter\@csv@extractdata\@csv@element\csvline
+\expandafter\toks@\expandafter{\csvline}%
+\edef\@csvlin@{\@csvseparator\the\toks@\@csvseparator}%
+\long\edef\@csvlin@{\@csvseparator\csvline\@csvseparator}%
+\c@field=0\relax
+\whiledo{\not\equal{\@csvlin@}{\@csvseparator}}{%
+\extractentry{\@csvlin@}{\param}%
+\expandafter\toks@\expandafter{\param}%
+\advance\c@field by 1\relax
+\expandafter\xdef\csname @field\romannumeral\c@field\endcsname{%
+\the\toks@}%
+\edef\@fieldlabel{%
+\csname @fieldlabel\romannumeral\c@field\endcsname}%
+\expandafter\xdef\csname insert\@fieldlabel\endcsname{\the\toks@}%
+}%
+\ifthenelse{\not\equal{\csvline}{}}{%
+\refstepcounter{csvrownumber}%
+#3}{}%
+}%
+\egroup
+}
+\newcommand{\sortCSVtotabular}[6][]{%
+\@sortCSVtotabular[#1]{#2}{#3}{#4}{#5}{#6}{tabular}}
+\newcommand{\sortCSVtolongtable}[6][]{%
+\@sortCSVtotabular[#1]{#2}{#3}{#4}{#5}{#6}{longtable}}
+\newcommand{\@sortCSVtotabular}[7][]{%
+\bgroup
+\setkeys{csvsort.sty}{#1}%
+\def\@csv@list{}%
+\@applyCSVfile[\c@firstdataline]{#2}{%
+\edef\csv@key{\csv@sortvariable}%
+\if\relax\@csv@list\relax
+\protected@xdef\@csv@list{{\csv@key}{\csvline}}%
+\else
+\protected@xdef\@csv@list{\@csv@list,{\csv@key}{\csvline}}%
+\fi
+}%
+\sortCSVdatatotabular{\c@csvrownumber}{\@csv@list}{#3}{#4}{#5}{#6}{#7}%
+\egroup
+}
+\newcommand{\sortCSVdatatotabular}[7]{%
+\maxlines=#1\relax
+\csv@insertionsort{#2}%
+\csvlastbutone=\maxlines
+\advance\csvlastbutone by -1\relax
+\c@csvrownumber=0\relax
+\c@csvlinenum=0\relax
+\def\@r@wh{#4}\def\@r@w{}\def\@r@wl{}%
+\@for\@csv@element:=#2\do{%
+\expandafter\@csv@extractdata\@csv@element\csvline
+\expandafter\toks@\expandafter{\csvline}%
+\edef\@csvlin@{\@csvseparator\the\toks@\@csvseparator}%
+\long\edef\@csvlin@{\@csvseparator\csvline\@csvseparator}%
+\c@field=0\relax
+\whiledo{\not\equal{\@csvlin@}{\@csvseparator}}{%
+\extractentry{\@csvlin@}{\param}%
+\expandafter\toks@\expandafter{\param}%
+\advance\c@field by 1\relax
+\expandafter\xdef\csname @field\romannumeral\c@field\endcsname{%
+\the\toks@}%
+\edef\@fieldlabel{%
+\csname @fieldlabel\romannumeral\c@field\endcsname}%
+\expandafter\xdef\csname insert\@fieldlabel\endcsname{\the\toks@}%
+}%
+\refstepcounter{csvrownumber}%
+\refstepcounter{csvlinenum}%
+\ifnum\c@csvrownumber=\maxlines
+ \protected@edef\@r@wl{#6}%
+\else
+ \expandafter\toks@\expandafter{\@r@w}
+ \protected@edef\@r@w{\the\toks@#5}%
+\fi
+}%
+\begin{#7}{#3}%
+\@r@wh
+\@r@w
+\@r@wl
+\end{#7}%
+}
+\endinput
+%%
+%% End of file `csvsort.sty'.