diff options
author | Karl Berry <karl@freefriends.org> | 2016-07-01 22:04:23 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2016-07-01 22:04:23 +0000 |
commit | 66ccb4e6d9726069a12743ef1a0fa735cdd22b26 (patch) | |
tree | f15ddb00578ce5f117074596179fe940372d7872 | |
parent | 0ee8d441c29c80ef0ca37b141bce0801948328da (diff) |
csvsimple (1jul16)
git-svn-id: svn://tug.org/texlive/trunk@41597 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Master/texmf-dist/doc/latex/csvsimple/CHANGES | 17 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/csvsimple/README | 5 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/csvsimple/csvsimple-example.pdf | bin | 72221 -> 72195 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/csvsimple/csvsimple-example.tex | 4 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/csvsimple/csvsimple.pdf | bin | 840011 -> 798411 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/csvsimple/csvsimple.tex | 588 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/csvsimple/encoding.xml | 6 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/csvsimple/csvsimple.sty | 149 |
8 files changed, 561 insertions, 208 deletions
diff --git a/Master/texmf-dist/doc/latex/csvsimple/CHANGES b/Master/texmf-dist/doc/latex/csvsimple/CHANGES index 01716414ecc..5923b9fd100 100644 --- a/Master/texmf-dist/doc/latex/csvsimple/CHANGES +++ b/Master/texmf-dist/doc/latex/csvsimple/CHANGES @@ -1,7 +1,7 @@ -%% The LaTeX package csvsimple - version 1.12 (2014/07/14) +%% The LaTeX package csvsimple - version 1.20 (2016/07/01) %% %% ------------------------------------------------------------------------------------------- -%% Copyright (c) 2008-2014 by Prof. Dr. Dr. Thomas F. Sturm <thomas dot sturm at unibw dot de> +%% Copyright (c) 2008-2016 by Prof. Dr. Dr. Thomas F. Sturm <thomas dot sturm at unibw dot de> %% ------------------------------------------------------------------------------------------- %% %% This work may be distributed and/or modified under the @@ -89,3 +89,16 @@ version 1.12 (2014/07/14): new key 'csvsorter token' - changed: encircling column entry braces removed for all entries for better siunitx compatibility - documentation revised and extended with siunitx examples + +version 1.20 (2016/07/01): +- implementation changed from \roman to \romannumeral +- write18 replace by \ShellEscape from the shellesc package +- '\csvlinetotablerow' implemented more efficiently +- '\csvloop' made long +- new string comparison macros: + '\ifcsvstrequal', '\ifcsvprostrequal', '\ifcsvstrcmp', '\ifcsvnotstrcmp' +- new filter options: + 'filter ifthen', 'filter test', 'filter expr', 'full filter', + 'filter strcmp', 'filter not strcmp' +- code optimizations +- documentation revised diff --git a/Master/texmf-dist/doc/latex/csvsimple/README b/Master/texmf-dist/doc/latex/csvsimple/README index a381c139032..85d4812d1eb 100644 --- a/Master/texmf-dist/doc/latex/csvsimple/README +++ b/Master/texmf-dist/doc/latex/csvsimple/README @@ -1,7 +1,7 @@ -%% The LaTeX package csvsimple - version 1.12 (2014/07/14) +%% The LaTeX package csvsimple - version 1.20 (2016/07/01) %% %% ------------------------------------------------------------------------------------------- -%% Copyright (c) 2008-2014 by Prof. Dr. Dr. Thomas F. Sturm <thomas dot sturm at unibw dot de> +%% Copyright (c) 2008-2016 by Prof. Dr. Dr. Thomas F. Sturm <thomas dot sturm at unibw dot de> %% ------------------------------------------------------------------------------------------- %% %% This work may be distributed and/or modified under the @@ -35,6 +35,7 @@ Contents of the package 'csvsimple-example.pdf' Compiled example 'amountsort.xml' csvsorter configuration file (example) 'catsort.xml' csvsorter configuration file (example) + 'encoding.xml' csvsorter configuration file (example) 'gradesort.xml' csvsorter configuration file (example) 'matriculationsort.xml' csvsorter configuration file (example) 'namesort.xml' csvsorter configuration file (example) diff --git a/Master/texmf-dist/doc/latex/csvsimple/csvsimple-example.pdf b/Master/texmf-dist/doc/latex/csvsimple/csvsimple-example.pdf Binary files differindex 4d61bebec6e..c53b71c6df1 100644 --- a/Master/texmf-dist/doc/latex/csvsimple/csvsimple-example.pdf +++ b/Master/texmf-dist/doc/latex/csvsimple/csvsimple-example.pdf diff --git a/Master/texmf-dist/doc/latex/csvsimple/csvsimple-example.tex b/Master/texmf-dist/doc/latex/csvsimple/csvsimple-example.tex index fd17a30ca08..b5d25092c99 100644 --- a/Master/texmf-dist/doc/latex/csvsimple/csvsimple-example.tex +++ b/Master/texmf-dist/doc/latex/csvsimple/csvsimple-example.tex @@ -1,8 +1,8 @@ -%% The LaTeX package csvsimple - version 1.12 (2014/07/14) +%% The LaTeX package csvsimple - version 1.20 (2016/07/01) %% csvsimple-example.tex: an example for csvsimple %% %% ------------------------------------------------------------------------------------------- -%% Copyright (c) 2008-2014 by Prof. Dr. Dr. Thomas F. Sturm <thomas dot sturm at unibw dot de> +%% Copyright (c) 2008-2016 by Prof. Dr. Dr. Thomas F. Sturm <thomas dot sturm at unibw dot de> %% ------------------------------------------------------------------------------------------- %% %% This work may be distributed and/or modified under the diff --git a/Master/texmf-dist/doc/latex/csvsimple/csvsimple.pdf b/Master/texmf-dist/doc/latex/csvsimple/csvsimple.pdf Binary files differindex 475b6fdd9c0..14e965f6cf5 100644 --- a/Master/texmf-dist/doc/latex/csvsimple/csvsimple.pdf +++ b/Master/texmf-dist/doc/latex/csvsimple/csvsimple.pdf diff --git a/Master/texmf-dist/doc/latex/csvsimple/csvsimple.tex b/Master/texmf-dist/doc/latex/csvsimple/csvsimple.tex index d27e864b673..f4680a389fe 100644 --- a/Master/texmf-dist/doc/latex/csvsimple/csvsimple.tex +++ b/Master/texmf-dist/doc/latex/csvsimple/csvsimple.tex @@ -1,9 +1,10 @@ % \LaTeX-Main\ -%% The LaTeX package csvsimple - version 1.12 (2014/07/14) +% !TeX encoding=UTF-8 +%% The LaTeX package csvsimple - version 1.20 (2016/07/01) %% csvsimple.tex: Manual %% %% ------------------------------------------------------------------------------------------- -%% Copyright (c) 2008-2014 by Prof. Dr. Dr. Thomas F. Sturm <thomas dot sturm at unibw dot de> +%% Copyright (c) 2008-2016 by Prof. Dr. Dr. Thomas F. Sturm <thomas dot sturm at unibw dot de> %% ------------------------------------------------------------------------------------------- %% %% This work may be distributed and/or modified under the @@ -21,17 +22,19 @@ \documentclass[a4paper,11pt]{ltxdoc} \usepackage[T1]{fontenc} -\usepackage[latin1]{inputenc} +\usepackage[utf8]{inputenc} \usepackage[english]{babel} \usepackage{lmodern,parskip,array,ifthen,calc,makeidx} \usepackage{amsmath,amssymb} \usepackage[svgnames,table,hyperref]{xcolor} \usepackage{tikz,siunitx} +\usepackage{varioref} \usepackage[pdftex,bookmarks,raiselinks,pageanchor,hyperindex,colorlinks]{hyperref} \urlstyle{sf} +\usepackage{cleveref} \usepackage[a4paper,left=2.5cm,right=2.5cm,top=1.5cm,bottom=1.5cm, - marginparsep=5mm,marginparwidth=10mm, + marginparsep=3mm,marginparwidth=18mm, headheight=0mm,headsep=0cm, footskip=1.5cm,includeheadfoot]{geometry} \usepackage{fancyhdr} @@ -51,54 +54,64 @@ \setlength{\bibitemsep}{\smallskipamount} \addbibresource{\jobname.bib} -\usepackage[most,documentation]{tcolorbox} \usepackage{longtable,booktabs} \usepackage{csvsimple} +\usepackage{tcolorbox} +\tcbuselibrary{skins,xparse,minted,breakable,documentation,raster} + +\definecolor{Green_Dark}{rgb}{0.078431,0.407843,0.176471} +\definecolor{Blue_Dark}{rgb}{0.090196,0.211765,0.364706} +\definecolor{Blue_Bright}{rgb}{0.858824,0.898039,0.945098} + \tcbset{skin=enhanced, + minted options={fontsize=\footnotesize}, doc head={colback=yellow!10!white,interior style=fill}, doc head key={colback=magenta!5!white,interior style=fill}, color key=DarkViolet, color value=Teal, color color=Teal, - index colorize,index annotate} - -\lstdefinestyle{mydocumentation}{style=tcbdocumentation, - classoffset=0, - texcsstyle=\color{blue}, - % LaTeX and other packages - moretexcs={arrayrulecolor,draw,includegraphics,ifthenelse,isodd,lipsum,path,pgfkeysalso}, - classoffset=1, - moretexcs={% - csvset,csvreader,csvautotabular,csvloop,csvautolongtable,csvstyle, - csvnames,csvheadset,csviffirstrow,csvifoddrow,csvfilteraccept, - csvfilterreject,csvline,thecsvrow,thecsvinputline,csvlinetotablerow, - csvautobooktabular,csvautobooklongtable, - }, - texcsstyle=\color{Definition}\bfseries, - classoffset=2, - keywordstyle=\color{Option}\bfseries, - % option list - morekeywords={% + color counter=Orange!85!black, + color length=Orange!85!black, + index colorize, + index annotate, + beforeafter example/.style={ + before skip=4pt plus 2pt minus 1pt, + after skip=8pt plus 4pt minus 2pt + }, + docexample/.style={bicolor, + beforeafter example, + arc is angular,fonttitle=\bfseries, + %fontupper=\tiny\itshape, + fontlower=\footnotesize, + %colframe=Blue_Dark, + %colback=Blue_Bright!75, + colframe=green!25!yellow!50!black, + colback=green!25!yellow!7, + colbacklower=white, +% drop fuzzy shadow, + drop fuzzy shadow=green!25!yellow!50!black, + listing engine=minted, + documentation minted style=colorful, + documentation minted options={fontsize=\footnotesize}, }, - classoffset=0% restore default - } - -\tcbset{documentation listing style=mydocumentation,% - docexample/.style={enhanced,colframe=Navy!50!ExampleFrame,colback=Navy!5!ExampleBack,fontlower=\footnotesize, - bicolor,colbacklower=ExampleBack!5!white,drop fuzzy shadow}, } - +\renewcommand*{\tcbdocnew}[1]{\textcolor{green!50!black}{\sffamily\bfseries N} #1} +\renewcommand*{\tcbdocupdated}[1]{\textcolor{blue!75!black}{\sffamily\bfseries U} #1} \tcbmakedocSubKey{docCsvKey}{csv} \NewDocumentCommand{\csvsorter}{}{\textsf{\bfseries\color{red!20!black}CSV-Sorter}} -\newtcbinputlisting{\csvlisting}[1]{docexample,listing style=tcbdocumentation,fonttitle=\bfseries, - listing only,title={CSV file \flqq\texttt{\detokenize{#1.csv}}\frqq},listing file=#1.csv} +%\newtcbinputlisting{\csvlisting}[1]{docexample,listing style=tcbdocumentation,fonttitle=\bfseries, +% listing only,title={CSV file \flqq\texttt{\detokenize{#1.csv}}\frqq},listing file=#1.csv} +\newtcbinputlisting{\csvlisting}[1]{docexample,minted options={fontsize=\footnotesize},minted language=latex, + fonttitle=\bfseries,listing only,title={CSV file \flqq\texttt{\detokenize{#1.csv}}\frqq},listing file=#1.csv} -\newtcbinputlisting{\xmllisting}[1]{docexample,listing options={style=tcbdocumentation,language=XML}, +%\newtcbinputlisting{\xmllisting}[1]{docexample,listing options={style=tcbdocumentation,language=XML}, +% fonttitle=\bfseries,listing only,title={Configuration file \flqq\texttt{\detokenize{#1.xml}}\frqq},listing file=#1.xml} +\newtcbinputlisting{\xmllisting}[1]{docexample,minted options={fontsize=\footnotesize},minted language=xml, fonttitle=\bfseries,listing only,title={Configuration file \flqq\texttt{\detokenize{#1.xml}}\frqq},listing file=#1.xml} \NewTotalTCBox{\verbbox}{m}{enhanced,on line,size=fbox,frame empty,colback=red!5!white, @@ -111,25 +124,28 @@ pdfkeywords={csv file, comma separated values, key value syntax} } -\def\version{1.12}% -\def\datum{2014/07/14}% +\def\version{1.20}% +\def\datum{2016/07/01}% \makeindex %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{document} \begin{center} -\vspace*{5mm} -\begin{tcolorbox}[enhanced, - center upper,width=10cm,boxrule=0.4pt, - colback=white,colframe=black!50!yellow,drop fuzzy midday shadow=black!50!yellow] -{\bfseries\LARGE The \texttt{csvsimple} package\par}\medskip -{\large Manual for version \version\ (\datum)\par} -\end{tcolorbox}\bigskip +\begin{tcolorbox}[enhanced,hbox,tikznode,left=8mm,right=8mm,boxrule=0.4pt, + colback=white,colframe=black!50!yellow, + drop lifted shadow=black!50!yellow,arc is angular, + before=\par\vspace*{5mm},after=\par\bigskip] +{\bfseries\LARGE The \texttt{csvsimple} package}\\[3mm] +{\large Manual for version \version\ (\datum)} +\end{tcolorbox} {\large Thomas F.~Sturm% \footnote{Prof.~Dr.~Dr.~Thomas F.~Sturm, Institut f\"{u}r Mathematik und Informatik, Universit\"{a}t der Bundeswehr M\"{u}nchen, D-85577 Neubiberg, Germany; - email: \href{mailto:thomas.sturm@unibw.de}{thomas.sturm@unibw.de}} } + email: \href{mailto:thomas.sturm@unibw.de}{thomas.sturm@unibw.de}}\par\medskip +\normalsize\url{http://www.ctan.org/pkg/csvsimple}\par +\url{https://github.com/T-F-S/csvsimple} +} \end{center} \bigskip \begin{absquote} @@ -142,6 +158,7 @@ or data base storage. \end{absquote} +\clearpage \tableofcontents \clearpage @@ -149,10 +166,10 @@ The |csvsimple| package is applied to the processing of CSV\footnote{CSV file: file with comma separated values.} files. This processing is controlled by key value assignments according to the -syntax of |pgfkeys| \cite{tantau:2013a}. Sample applications of the package +syntax of |pgfkeys| \cite{tantau:2015a}. Sample applications of the package are tabular lists, serial letters, and charts. -An alternative to |csvsimple| is the |datatool| package \cite{talbot:2014a} +An alternative to |csvsimple| is the |datatool| package \cite{talbot:2016a} which provides considerably more functions and allows sorting of data by \LaTeX. |csvsimple| has a different approach for the user interface and is deliberately restricted to some basic functions with fast @@ -161,16 +178,18 @@ with external tools, see Section~\ref{sec:Sorting} on page~\pageref{sec:Sorting} \subsection{Loading the Package} The package |csvsimple| loads the packages -|pgfkeys| \cite{tantau:2013a} and |ifthen| \cite{carlisle:2001b}. +|pgfkeys| \cite{tantau:2015a}, +|etoolbox| \cite{lehmann:2015a}, +and |ifthen| \cite{carlisle:2014c}. |csvsimple| itself is loaded in the usual manner in the preamble: \begin{dispListing} \usepackage{csvsimple} \end{dispListing} Not automatically loaded, but used for many examples are the packages -|longtable| \cite{carlisle:2004a} +|longtable| \cite{carlisle:2014d} and -|booktabs| \cite{fear:2005a}. +|booktabs| \cite{fear:2016a}. \subsection{First Steps} Every line of a processable CSV file has to contain an identical amount of @@ -185,7 +204,7 @@ which contains the identifiers for each column. name,givenname,matriculation,gender,grade Maier,Hans,12345,m,1.0 Huber,Anna,23456,f,2.3 -Wei\ss{}b\"{a}ck,Werner,34567,m,5.0 +Weißbäck,Werner,34567,m,5.0 Bauer,Maria,19202,f,3.3 \end{tcbverbatimwrite} %-- end embedded file -- @@ -330,10 +349,10 @@ The data lines of a CSV file can also be filtered. In the following example, a certificate is printed only for students with grade unequal to 5.0. \begin{dispExample} -\csvreader[filter not equal={\grade}{5.0}]% +\csvreader[filter not strcmp={\grade}{5.0}]% {grade.csv}{1=\name,2=\firstname,3=\matnumber,4=\gender,5=\grade}% {\begin{center}\Large\bfseries Certificate in Mathematics\end{center} - \large\ifthenelse{\equal{\gender}{f}}{Ms.}{Mr.} + \large\ifcsvstrcmp{\gender}{f}{Ms.}{Mr.} \firstname~\name, matriculation number \matnumber, has passed the test in mathematics with grade \grade.\par\ldots\par }% @@ -480,7 +499,7 @@ for the general table options in combination with \refCom{csvreader} and \begin{dispExample} \csvset{grade list/.style= {column names={name=\name,givenname=\firstname,grade=\grade}}, - passed/.style={filter not equal={\grade}{5.0}} } + passed/.style={filter not strcmp={\grade}{5.0}} } The following students passed the test in mathematics: \csvreader[grade list,passed]{grade.csv}{}{\firstname\ \name\ (\grade); }% @@ -498,7 +517,7 @@ The following students passed the test in mathematics: to define additional \meta{assignments} of macros to columns. \begin{dispExample} \csvnames{grade list}{name=\name,givenname=\firstname,grade=\grade} -\csvstyle{passed}{filter not equal={\grade}{5.0}} +\csvstyle{passed}{filter not strcmp={\grade}{5.0}} The following students passed the test in mathematics: \csvreader[grade list,passed]{grade.csv}{}{\firstname\ \name\ (\grade); }% @@ -575,11 +594,11 @@ purpose: \begin{docCommand}{csvfilteraccept}{} All following consistent data lines will be accepted and processed. This command overwrites all previous filter settings and may be used - inside \refKey{/csv/before filter} to implement + inside \refKey{/csv/full filter} to implement an own filtering rule together with |\csvfilterreject|. \begin{dispExample} \csvreader[autotabular, - before filter=\ifthenelse{\equal{\csvcoliv}{m}}{\csvfilteraccept}{\csvfilterreject} + full filter=\ifcsvstrcmp{\csvcoliv}{m}{\csvfilteraccept}{\csvfilterreject} ]{grade.csv}{}{\csvlinetotablerow}% \end{dispExample} \end{docCommand} @@ -614,14 +633,14 @@ purpose: The \LaTeX\ counter |csvinputline| can be addressed directly in the usual way, e.\,g. by |\roman{csvinputline}|. \begin{dispExample} -\csvreader[no head, filter equal={\thecsvinputline}{3}]% +\csvreader[no head, filter test=\ifnumequal{\thecsvinputline}{3}]% {grade.csv}{}% {The line with number \thecsvinputline\ contains: \csvline}% \end{dispExample} \end{docCommand} -\begin{docCommand}{csvlinetotablerow}{} +\begin{docCommand}[doc updated=2016-00-00]{csvlinetotablerow}{} Typesets the current processed data line with |&| between the entries. %Most users will never apply this command. \end{docCommand} @@ -637,28 +656,29 @@ to be used inside these macros. \subsection{Command Definition}%--------%[[ -\begin{docCsvKey}{before reading}{=\meta{macros}}{no default, initially empty} - Sets the \meta{macros} to be executed before the CSV file is processed. +\begin{docCsvKey}{before reading}{=\meta{code}}{no default, initially empty} + Sets the \meta{code} to be executed before the CSV file is processed. \end{docCsvKey} -\begin{docCsvKey}{after head}{=\meta{macros}}{no default, initially empty} - Sets the \meta{macros} to be executed after the header line is read. +\begin{docCsvKey}{after head}{=\meta{code}}{no default, initially empty} + Sets the \meta{code} to be executed after the header line is read. \end{docCsvKey} -\begin{docCsvKey}{before filter}{=\meta{macros}}{no default, initially empty} - Sets the \meta{macros} to be executed after reading and consistency checking +\begin{docCsvKey}{before filter}{=\meta{code}}{no default, initially empty} + Sets the \meta{code} to be executed after reading and consistency checking of a data line. They are executed before any filter condition is checked, see \refKey{/csv/filter}. + Also see \refKey{/csv/full filter}. \end{docCsvKey} -\begin{docCsvKey}{late after head}{=\meta{macros}}{no default, initially empty} - Sets the \meta{macros} to be executed after reading and disassembling +\begin{docCsvKey}{late after head}{=\meta{code}}{no default, initially empty} + Sets the \meta{code} to be executed after reading and disassembling of the first accepted data line. They are executed before further processing of this line. \end{docCsvKey} -\begin{docCsvKey}{late after line}{=\meta{macros}}{no default, initially empty} - Sets the \meta{macros} to be executed after reading and disassembling +\begin{docCsvKey}{late after line}{=\meta{code}}{no default, initially empty} + Sets the \meta{code} to be executed after reading and disassembling of the next accepted data line (after \refKey{/csv/before filter}). They are executed before further processing of this next line. |late after line| overwrites |late after first line| and |late after last line|. @@ -667,55 +687,55 @@ to be used inside these macros. \end{docCsvKey} -\begin{docCsvKey}{late after first line}{=\meta{macros}}{no default, initially empty} - Sets the \meta{macros} to be executed after reading and disassembling +\begin{docCsvKey}{late after first line}{=\meta{code}}{no default, initially empty} + Sets the \meta{code} to be executed after reading and disassembling of the second accepted data line instead of \refKey{/csv/late after line}. This key has to be set after |late after line|. \end{docCsvKey} -\begin{docCsvKey}{late after last line}{=\meta{macros}}{no default, initially empty} - Sets the \meta{macros} to be executed after processing of the last +\begin{docCsvKey}{late after last line}{=\meta{code}}{no default, initially empty} + Sets the \meta{code} to be executed after processing of the last accepted data line instead of \refKey{/csv/late after line}. This key has to be set after |late after line|. \end{docCsvKey} -\begin{docCsvKey}{before line}{=\meta{macros}}{no default, initially empty} - Sets the \meta{macros} to be executed after \refKey{/csv/late after line} +\begin{docCsvKey}{before line}{=\meta{code}}{no default, initially empty} + Sets the \meta{code} to be executed after \refKey{/csv/late after line} and before \refKey{/csv/command}. |before line| overwrites |before first line|. \end{docCsvKey} -\begin{docCsvKey}{before first line}{=\meta{macros}}{no default, initially empty} - Sets the \meta{macros} to be executed instead of \refKey{/csv/before line} +\begin{docCsvKey}{before first line}{=\meta{code}}{no default, initially empty} + Sets the \meta{code} to be executed instead of \refKey{/csv/before line} for the first accepted data line. This key has to be set after |before line|. \end{docCsvKey} -\begin{docCsvKey}{command}{=\meta{macros}}{no default, initially \cs{csvline}} - Sets the \meta{macros} to be executed for every accepted data line. +\begin{docCsvKey}{command}{=\meta{code}}{no default, initially \cs{csvline}} + Sets the \meta{code} to be executed for every accepted data line. They are executed between \refKey{/csv/before line} and \refKey{/csv/after line}. \end{docCsvKey} -\begin{docCsvKey}{after line}{=\meta{macros}}{no default, initially empty} - Sets the \meta{macros} to be executed for every accepted data line +\begin{docCsvKey}{after line}{=\meta{code}}{no default, initially empty} + Sets the \meta{code} to be executed for every accepted data line after \refKey{/csv/command}. |after line| overwrites |after first line|. \end{docCsvKey} -\begin{docCsvKey}{after first line}{=\meta{macros}}{no default, initially empty} - Sets the \meta{macros} to be executed instead of \refKey{/csv/after line} +\begin{docCsvKey}{after first line}{=\meta{code}}{no default, initially empty} + Sets the \meta{code} to be executed instead of \refKey{/csv/after line} for the first accepted data line. This key has to be set after |after line|. \end{docCsvKey} -\begin{docCsvKey}{after reading}{=\meta{macros}}{no default, initially empty} - Sets the \meta{macros} to be executed after the CSV file is processed. +\begin{docCsvKey}{after reading}{=\meta{code}}{no default, initially empty} + Sets the \meta{code} to be executed after the CSV file is processed. \end{docCsvKey} @@ -777,7 +797,7 @@ see section \ref{subsec:tabsupport} from page \clearpage -\subsection{Consistency Check and Filtering}% +\subsection{Consistency Check}% \begin{docCsvKey}{check column count}{\colOpt{=true\textbar false}}{default |true|, initially |true|} This key defines, if the number of entries in a data line is checked against @@ -801,8 +821,8 @@ see section \ref{subsec:tabsupport} from page \end{docCsvKey} -\begin{docCsvKey}{on column count error}{=\meta{macros}}{no default, initially empty} - \meta{macros} to be executed for unfeasible data lines. +\begin{docCsvKey}{on column count error}{=\meta{code}}{no default, initially empty} + \meta{code} to be executed for unfeasible data lines. \end{docCsvKey} @@ -811,14 +831,107 @@ see section \ref{subsec:tabsupport} from page \end{docCsvKey} -\begin{docCsvKey}{filter}{=\meta{condition}}{no default} +\clearpage +\subsection{Filtering}% + +\begin{docCsvKey}[][doc new=2016-00-00]{filter test}{=\meta{condition}}{no default} + Only data lines which fulfill a logical \meta{condition} are accepted. + For the \meta{condition}, every single test normally employed like +\begin{dispListing} +\iftest{some testing}{true}{false} +\end{dispListing} + can be used as +\begin{dispListing} +filter test=\iftest{some testing}, +\end{dispListing} + For |\iftest|, tests from the |etoolbox| package \cite{lehmann:2015a} like + |\ifnumcomp|, |\ifdimgreater|, etc. and from \Fullref{sec:stringtests} can be used. + +\begin{dispExample} +\csvreader[head to column names,tabular=llll, + table head=\toprule & \bfseries Name & \bfseries Matr & \bfseries Grade\\\midrule, + table foot=\bottomrule, + %>> list only matriculation numbers greater than 20000 << + filter test=\ifnumgreater{\matriculation}{20000}, + ]{grade.csv}{}{% + \thecsvrow & \slshape\name, \givenname & \matriculation & \grade} +\end{dispExample} +\end{docCsvKey} + + +\begin{docCsvKey}{filter strcmp}{=\marg{stringA}\marg{stringB}}{style, no default} + Only lines where \meta{stringA} and \meta{stringB} are equal after expansion + are accepted. + The implementation is done with \refCom{ifcsvstrcmp}. +\end{docCsvKey} + + +\begin{docCsvKey}{filter not strcmp}{=\marg{stringA}\marg{stringB}}{style, no default} + Only lines where \meta{stringA} and \meta{stringB} are not equal after expansion + are accepted. + The implementation is done with \refCom{ifcsvnotstrcmp}. +\end{docCsvKey} + + +\begin{docCsvKey}[][doc new=2016-00-00]{filter expr}{=\meta{condition}}{no default} + Only data lines which fulfill a logical \meta{condition} are accepted. + For the \meta{condition}, every boolean expression + from the |etoolbox| package \cite{lehmann:2015a} is feasible. + To preprocess the data line before testing the \meta{condition}, + the option key \refKey{/csv/before filter} can be used. +\begin{dispExample} +\csvreader[head to column names,tabular=llll, + table head=\toprule & \bfseries Name & \bfseries Matr & \bfseries Grade\\\midrule, + table foot=\bottomrule, + %>> list only matriculation numbers greater than 20000 + % and grade less than 4.0 << + filter expr={ test{\ifnumgreater{\matriculation}{20000}} + and test{\ifdimless{\grade pt}{4.0pt}} }, + ]{grade.csv}{}{% + \thecsvrow & \slshape\name, \givenname & \matriculation & \grade} +\end{dispExample} +\end{docCsvKey} + +\clearpage +\begin{docCsvKey}[][doc new=2016-00-00]{filter ifthen}{=\meta{condition}}{no default} Only data lines which fulfill a logical \meta{condition} are accepted. - For the \meta{condition}, every term from the |ifthen| package \cite{carlisle:2001b} + For the \meta{condition}, every term from the |ifthen| \cite{carlisle:2014c} package is feasible. To preprocess the data line before testing the \meta{condition}, the option key \refKey{/csv/before filter} can be used. + +\begin{dispExample} +\csvreader[head to column names,tabular=llll, + table head=\toprule & \bfseries Name & \bfseries Matr & \bfseries Grade\\\midrule, + table foot=\bottomrule, + %>> list only female persons << + filter ifthen=\equal{\gender}{f}, + ]{grade.csv}{}{% + \thecsvrow & \slshape\name, \givenname & \matriculation & \grade} +\end{dispExample} + +\end{docCsvKey} + + +\begin{docCsvKey}{filter}{=\meta{condition}}{no default} + Alias for \refKey{/csv/filter ifthen}. +\end{docCsvKey} + +\begin{docCsvKey}{filter equal}{=\marg{stringA}\marg{stringB}}{style, no default} + Only lines where \meta{stringA} and \meta{stringB} are equal after expansion + are accepted. + The implementation is done with the |ifthen| \cite{carlisle:2014c} package. +\end{docCsvKey} + + +\begin{docCsvKey}{filter not equal}{=\marg{stringA}\marg{stringB}}{style, no default} + Only lines where \meta{stringA} and \meta{stringB} are not equal after expansion + are accepted. + The implementation is done with the |ifthen| \cite{carlisle:2014c} package. \end{docCsvKey} + + \begin{docCsvKey}{no filter}{}{no value, initially set} Clears a set filter. \end{docCsvKey} @@ -834,18 +947,30 @@ see section \ref{subsec:tabsupport} from page \end{docCsvKey} -\begin{docCsvKey}{filter equal}{=\marg{string A}\marg{string B}}{style, no default} - Only lines where \meta{string A} and \meta{string B} are equal after expansion - are accepted. -\end{docCsvKey} - -\begin{docCsvKey}{filter not equal}{=\marg{string A}\marg{string B}}{style, no default} - Only lines where \meta{string A} and \meta{string B} are not equal after expansion - are accepted. +\enlargethispage*{2cm} +\begin{docCsvKey}[][doc new=2016-00-00]{full filter}{=\meta{code}}{no default} + Technically, this key is an alias for \refKey{/csv/before filter}. + Philosophically, \refKey{/csv/before filter} computes something before + a filter condition is set, but \refKey{/csv/full filter} should implement + the full filtering. Especially, \refCom{csvfilteraccept} or + \refCom{csvfilterreject} \emph{should} be set inside the \meta{code}. +\begin{dispExample} +\csvreader[head to column names,tabular=llll, + table head=\toprule & \bfseries Name & \bfseries Matr & \bfseries Grade\\\midrule, + table foot=\bottomrule, + %>> list only matriculation numbers greater than 20000 + % and grade less than 4.0 << + full filter=\ifnumgreater{\matriculation}{20000} + {\ifdimless{\grade pt}{4.0pt}{\csvfilteraccept}{\csvfilterreject}} + {\csvfilterreject}, + ]{grade.csv}{}{% + \thecsvrow & \slshape\name, \givenname & \matriculation & \grade} +\end{dispExample} \end{docCsvKey} + %]] @@ -887,26 +1012,26 @@ Additionally, the commands defined by the key values of \end{docCsvKey} -\begin{docCsvKey}{before table}{=\meta{macros}}{no default, initially empty} - Sets the \meta{macros} to be executed before |\begin{tabular}| or before |\begin{longtable}| +\begin{docCsvKey}{before table}{=\meta{code}}{no default, initially empty} + Sets the \meta{code} to be executed before |\begin{tabular}| or before |\begin{longtable}| or before |\begin{tabbing}|, respectively. \end{docCsvKey} -\begin{docCsvKey}{table head}{=\meta{macros}}{no default, initially empty} - Sets the \meta{macros} to be executed after |\begin{tabular}| or after |\begin{longtable}| +\begin{docCsvKey}{table head}{=\meta{code}}{no default, initially empty} + Sets the \meta{code} to be executed after |\begin{tabular}| or after |\begin{longtable}| or after |\begin{tabbing}|, respectively. \end{docCsvKey} -\begin{docCsvKey}{table foot}{=\meta{macros}}{no default, initially empty} - Sets the \meta{macros} to be executed before |\end{tabular}| or before |\end{longtable}| +\begin{docCsvKey}{table foot}{=\meta{code}}{no default, initially empty} + Sets the \meta{code} to be executed before |\end{tabular}| or before |\end{longtable}| or before |\end{tabbing}|, respectively. \end{docCsvKey} -\begin{docCsvKey}{after table}{=\meta{macros}}{no default, initially empty} - Sets the \meta{macros} to be executed after |\end{tabular}| or after |\end{longtable}| +\begin{docCsvKey}{after table}{=\meta{code}}{no default, initially empty} + Sets the \meta{code} to be executed after |\end{tabular}| or after |\end{longtable}| or after |\end{tabbing}|, respectively. \end{docCsvKey} @@ -1038,7 +1163,7 @@ as normal characters, if one or more of the following options are used. name;givenname;matriculation;gender;grade Maier;Hans;12345;m;1.0 Huber;Anna;23456;f;2.3 - Wei\ss{}b\"{a}ck;Werner;34567;m;5.0 + Weißbäck;Werner;34567;m;5.0 \end{tcbverbatimwrite} \csvautobooktabular[separator=semicolon]{testsemi.csv} @@ -1052,7 +1177,7 @@ as normal characters, if one or more of the following options are used. name|givenname|matriculation|gender|grade Maier|Hans|12345|m|1.0 Huber|Anna|23456|f|2.3 - Wei\ss{}b\"{a}ck|Werner|34567|m|5.0 + Weißbäck|Werner|34567|m|5.0 \end{tcbverbatimwrite} \csvautobooktabular[separator=pipe]{pipe.csv} @@ -1178,26 +1303,26 @@ following options. If \csvsorter\ was completely installed following its documentation, there is nothing to change here. If the |csvsorter.jar| file is inside the same directory as the \LaTeX\ source file, you may configure:% preferrably inside the preamble: - \begin{dispListing} - \csvset{csvsorter command=java -jar csvsorter.jar} - \end{dispListing} +\begin{dispListing} +\csvset{csvsorter command=java -jar csvsorter.jar} +\end{dispListing} \end{docCsvKey} \begin{docCsvKey}{csvsorter configpath}{=\meta{path}}{no default, initially |.|} Sorting with \csvsorter\ is done using XML configuration files. If these files are not stored inside the same directory as the \LaTeX\ source file, a \meta{path} to access them can be configured: - \begin{dispListing} - \csvset{csvsorter configpath=xmlfiles} - \end{dispListing} +\begin{dispListing} +\csvset{csvsorter configpath=xmlfiles} +\end{dispListing} Here, the configuration files would be stored in a subdirectory named |xmlfiles|. \end{docCsvKey} \begin{docCsvKey}{csvsorter log}{=\meta{file name}}{no default, initially |csvsorter.log|} Sets the log file of \csvsorter\ to the given \meta{file name}. - \begin{dispListing} - \csvset{csvsorter log=outdir/csvsorter.log} - \end{dispListing} +\begin{dispListing} +\csvset{csvsorter log=outdir/csvsorter.log} +\end{dispListing} Here, the log file is written to a subdirectory named |outdir|. \end{docCsvKey} @@ -1205,9 +1330,9 @@ following options. \begin{docCsvKey}{csvsorter token}{=\meta{file name}}{no default, initially |\textbackslash jobname.csvtoken|} Sets \meta{file name} as token file. This is an auxiliary file which communicates the success of \csvsorter\ to |csvsimple|. - \begin{dispListing} - \csvset{csvsorter log=outdir/\jobname.csvtoken} - \end{dispListing} +\begin{dispListing} +\csvset{csvsorter log=outdir/\jobname.csvtoken} +\end{dispListing} Here, the token file is written to a subdirectory named |outdir|. \end{docCsvKey} @@ -1307,6 +1432,51 @@ Now, we can use the new rule: \end{docCsvKey} +\clearpage +\section{String Tests}\label{sec:stringtests}% + +The following string tests are complementing the string tests +from the |etoolbox| \cite{lehmann:2015a} package. They all do the same, i.e., +comparing expanded strings for equality. +\begin{itemize} +\item\refCom{ifcsvstrcmp} is the most efficient method, because it uses + native compiler string comparison (if available). +\item\refCom{ifcsvstrequal} does not rely on a compiler. It also is the + fallback implementation for \refCom{ifcsvstrcmp}, if there is no + native comparison method. +\item\refCom{ifcsvprostrequal} is possibly more failsafe than the other two + string tests. It may be used, if strings contain dirty things like |\textbf{A}|. +\end{itemize} +\medskip + +\begin{docCommand}[doc new=2016-00-00]{ifcsvstrcmp}{\marg{stringA}\marg{stringB}\marg{true}\marg{false}} + Compares two strings and executes \meta{true} if they are equal, and \meta{false} otherwise. + The comparison is done using |\pdfstrcmp|, if compilation is done with pdf\LaTeX. + The comparison is done using |\pdf@strcmp|, if the package |pdftexcmds| is + loaded and compilation is done with lua\LaTeX\ or Xe\LaTeX. + Otherwise, \refCom{ifcsvstrcmp} is identical to \refCom{ifcsvstrequal}. + This command cannot be used inside the preamble. +\end{docCommand} + + +\begin{docCommand}[doc new=2016-00-00]{ifcsvnotstrcmp}{\marg{stringA}\marg{stringB}\marg{true}\marg{false}} + Compares two strings and executes \meta{true} if they are \emph{not} equal, and \meta{false} otherwise. + The implementation uses \refCom{ifcsvstrcmp}. +\end{docCommand} + + +\begin{docCommand}[doc new=2016-00-00]{ifcsvstrequal}{\marg{stringA}\marg{stringB}\marg{true}\marg{false}} + Compares two strings and executes \meta{true} if they are equal, and \meta{false} otherwise. + The strings are expanded with |\edef| in the test. +\end{docCommand} + +\begin{docCommand}[doc new=2016-00-00]{ifcsvprostrequal}{\marg{stringA}\marg{stringB}\marg{true}\marg{false}} + Compares two strings and executes \meta{true} if they are equal, and \meta{false} otherwise. + The strings are expanded with |\protected@edef| in the test, i.e. parts of the + strings which are protected stay unexpanded. +\end{docCommand} + + \clearpage \section{Examples}% @@ -1321,8 +1491,8 @@ not given in very pretty format. name,givenname,gender,degree,street,zip,location,bonus Maier,Hans,m,,Am Bachweg 17,10010,Hopfingen,20 % next line with a comma in curly braces -Huber,Erna,f,Dr.,{Moosstra\ss{}e 32, Hinterschlag},10020,\"{O}rtingstetten,30 -Wei\ss{}b\"{a}ck,Werner,m,Prof. Dr.,Brauallee 10,10030,Klingenbach,40 +Huber,Erna,f,Dr.,{Moosstraße 32, Hinterschlag},10020,Örtingstetten,30 +Weißbäck,Werner,m,Prof. Dr.,Brauallee 10,10030,Klingenbach,40 % this line is ignored % Siebener , Franz,m, , Blaumeisenweg 12 , 10040 , Pardauz , 50 % preceding and trailing spaces in entries are removed % @@ -1348,13 +1518,13 @@ introduced. \begin{dispExample} % this example requires the tcolorbox package -\newcommand{\ifmale}[2]{\ifthenelse{\equal{\gender}{m}}{#1}{#2}} +\newcommand{\ifmale}[2]{\ifcsvstrcmp{\gender}{m}{#1}{#2}} \csvreader[head to column names]{address.csv}{}{% \begin{tcolorbox}[colframe=DarkGray,colback=White,arc=0mm,width=(\linewidth-2pt)/2, equal height group=letter,before=,after=\hfill,fonttitle=\bfseries, adjusted title={Letter to \name}] - \ifthenelse{\equal{\degree}{}}{\ifmale{Mr.}{Ms.}}{\degree}~\givenname~\name\\ + \ifcsvstrcmp{\degree}{}{\ifmale{Mr.}{Ms.}}{\degree}~\givenname~\name\\ \street\\\zip~\location \tcblower {\itshape Dear \ifmale{Sir}{Madam},}\\ @@ -1373,9 +1543,9 @@ For this example, we use some artificial statistical data given by a CSV file. \begin{tcbverbatimwrite}{data.csv} land,group,amount Bayern,A,1700 -Baden-W\"{u}rttemberg,A,2300 +Baden-Württemberg,A,2300 Sachsen,B,1520 -Th\"{u}ringen,A,1900 +Thüringen,A,1900 Hessen,B,2100 \end{tcbverbatimwrite} %-- end embedded file -- @@ -1564,10 +1734,10 @@ December, 2.2, 3.3e3 \csvlisting{data_numbers} -The |siunitx| \cite{wright:2013a} package provides a new column type |S| +The |siunitx| \cite{wright:2016a} package provides a new column type |S| which can align material using a number of different strategies. The following example demonstrates the application with CSV reading. -The package documentation \cite{wright:2013a} contains a huge amount +The package documentation \cite{wright:2016a} contains a huge amount of formatting options. \begin{dispExample} @@ -1583,6 +1753,32 @@ of formatting options. \end{dispExample} \clearpage +Special care is needed, if the \emph{first} column is to be formatted with +the column type |S|. The number detection of |siunitx| is disturbed by +the line reading code of |csvsimple| which actually is present at the +first column. To avoid this problem, the content of the first column +could be formatted not by the table format definition, but by using a +suitable |\tablenum| formatting directly, see |siunitx| \cite{wright:2016a}. + +Another and very nifty workaround suggested by Enrico Gregorio is to +add an invisible dummy column with |c@{}| as first column: + + +\begin{dispExample} +% \usepackage{siunitx,array,booktabs} +\csvloop{ + file=data_numbers.csv, + head to column names, + before reading=\centering\sisetup{table-number-alignment=center}, + tabular={c@{}S[table-format=2.2e1]S}, + table head= & \textbf{Cats} & \textbf{Dogs}\\\midrule, + command= & \cats & \dogs, + table foot=\bottomrule} +\end{dispExample} + + + +\clearpage Now, the preceding table shall be sorted by the \emph{cats} values. If the \csvsorter\ program is properly installed, see Subsection~\ref{sec:Sorting} on page~\pageref{sec:Sorting}, @@ -1617,9 +1813,9 @@ but this time without header. %-- file embedded for simplicity -- \begin{tcbverbatimwrite}{data_headless.csv} Bayern,A,1700 -Baden-W\"{u}rttemberg,A,2300 +Baden-Württemberg,A,2300 Sachsen,B,1520 -Th\"{u}ringen,A,1900 +Thüringen,A,1900 Hessen,B,2100 \end{tcbverbatimwrite} %-- end embedded file -- @@ -1668,7 +1864,7 @@ because there is no head, but the columns can be addressed by their numbers: \clearpage \subsection{Imported CSV data}\label{importeddata}% -If data is important from other applications, there is not always a choice +If data is imported from other applications, there is not always a choice to format in comma separated values with curly brackets. Consider the following example data file: @@ -1678,7 +1874,7 @@ Consider the following example data file: "name";"address";"email" "Frank Smith";"Yellow Road 123, Brimblsby";"frank.smith@organization.org" "Mary May";"Blue Alley 2a, London";"mmay@maybe.uk" -"Hans Meier";"Hauptstrasse 32, Berlin";"hans.meier@corporation.de" +"Hans Meier";"Hauptstraße 32, Berlin";"hans.meier@corporation.de" \end{tcbverbatimwrite} %-- end embedded file -- @@ -1715,35 +1911,115 @@ The file which is generated on-the-fly and which is actually read by \clearpage +\subsection{Encoding}\label{encoding}% +If the CSV file has a different encoding than the \LaTeX\ source file, +then special care is needed. + +\begin{itemize} +\item The most obvious treatment is to change the encoding of the CSV file + or the \LaTeX\ source file to match the other one (every good editor + supports such a conversion). This is the easiest choice, if there a no + good reasons against such a step. E.g., unfortunately, several tools + under Windows need the CSV file to be |cp1252| encoded while + the \LaTeX\ source file may need to be |utf8| encoded. + +\item The |inputenc| package allows to switch the encoding inside the + document, say from |utf8| to |cp1252|. Just be aware that you should only + use pure ASCII for additional texts inside the switched region. +\begin{dispListing} +% !TeX encoding=UTF-8 +% .... +\usepackage[utf8]{inputenc} +% .... +\begin{document} +% .... +\inputencoding{latin1}% only use ASCII from here, e.g. "Uberschrift +\csvreader[%... + ]{data_cp1252.csv}{%... + }{% .... + } +\inputencoding{utf8} +% .... +\end{document} +\end{dispListing} + +\item As a variant to the last method, the encoding switch can be done + using options from |csvsimple|: +\begin{dispListing} +% !TeX encoding=UTF-8 +% .... +\usepackage[utf8]{inputenc} +% .... +\begin{document} +% .... +% only use ASCII from here, e.g. "Uberschrift +\csvreader[%... + before reading=\inputencoding{latin1}, + after reading=\inputencoding{utf8}, + ]{data_cp1252.csv}{%... + }{% .... + } +% .... +\end{document} +\end{dispListing} + +\pagebreak\item +If the \csvsorter\ program is properly installed, +see Subsection~\ref{sec:Sorting} on page~\pageref{sec:Sorting}, +the CSV file can be re-encoded on-the-fly +with the following configuration file for \csvsorter: + +\xmllisting{encoding} + +\begin{dispListing} +% !TeX encoding=UTF-8 +% .... +\usepackage[utf8]{inputenc} +% .... +\begin{document} +% .... +\csvreader[%... + sort by=encoding.xml, + ]{data_cp1252.csv}{%... + }{% .... + } +% .... +\end{document} +\end{dispListing} + + +\end{itemize} + + + + +\clearpage % Actually, it is not a good idea to include the references like this! % Do not follow this bad example ... \begin{tcbverbatimwrite}{\jobname.bib} -@manual{tantau:2013a, +@manual{tantau:2015a, author = {Till Tantau}, title = {The TikZ and PGF Packages}, - subtitle = {Manual for version 3.0.0}, - url = {http://sourceforge.net/projects/pgf/}, - date = {2013-12-20}, + subtitle = {Manual for version 3.0.1a}, + url = {http://mirrors.ctan.org/graphics/pgf/base/doc/pgfmanual.pdf}, + date = {2015-08-29}, } - -@manual{carlisle:2001b, +@manual{carlisle:2014c, author = {David Carlisle}, title = {The ifthen package}, - url = {http://mirror.ctan.org/macros/latex/base/}, - Xnote = {}, - day = 26, - month = may, - year = 2001, + url = {http://mirror.ctan.org/macros/latex/base/ifthen.pdf}, + date = {2014-09-29}, language = {english} } -@manual{talbot:2014a, + +@manual{talbot:2016a, author = {Nicola L. C. Talbot}, - title = {User Manual for the datatool bundle version 2.20}, - url = {http://mirror.ctan.org/macros/latex/contrib/datatool/datatool.pdf}, - date = {2014-02-03}, + title = {User Manual for the datatool bundle version 2.25}, + url = {http://mirrors.ctan.org/macros/latex/contrib/datatool/datatool-user.pdf}, + date = {2016-01-18}, } @manual{sturm:2014j, @@ -1755,30 +2031,38 @@ The file which is generated on-the-fly and which is actually read by language = {english} } -@manual{carlisle:2004a, +@manual{carlisle:2014d, author = {David Carlisle}, title = {The longtable package}, url = {http://mirror.ctan.org/macros/latex/required/tools/longtable.pdf}, - date = {2004-02-01}, + date = {2014-10-28}, language = {english} } -@manual{fear:2005a, + +@manual{fear:2016a, author = {Simon Fear}, title = {Publication quality tables in \LaTeX}, url = {http://mirror.ctan.org/macros/latex/contrib/booktabs/booktabs.pdf}, - date = {2005-04-15}, + date = {2016-04-29}, language = {english} } -@manual{wright:2013a, +@manual{wright:2016a, author = {Joseph Wright}, title = {siunitx --- A comprehensive (SI) units package}, url = {http://mirror.ctan.org/macros/latex/contrib/siunitx/siunitx.pdf}, - date = {2013-07-31}, + date = {2016-03-01}, language = {english} } +@manual{lehmann:2015a, + author = {Philipp Lehman and Joseph Wright}, + title = {The etoolbox Package}, + url = {http://mirror.ctan.org/macros/latex/contrib/etoolbox/etoolbox.pdf}, + date = {2015-08-02}, +} + \end{tcbverbatimwrite} diff --git a/Master/texmf-dist/doc/latex/csvsimple/encoding.xml b/Master/texmf-dist/doc/latex/csvsimple/encoding.xml new file mode 100644 index 00000000000..e43cb6a8de2 --- /dev/null +++ b/Master/texmf-dist/doc/latex/csvsimple/encoding.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<csv> + <noHeader/> + <bracket empty="true"/> + <charset in="windows-1252" out="UTF-8"/> +</csv> diff --git a/Master/texmf-dist/tex/latex/csvsimple/csvsimple.sty b/Master/texmf-dist/tex/latex/csvsimple/csvsimple.sty index 18345ebd5cd..7ab590e149e 100644 --- a/Master/texmf-dist/tex/latex/csvsimple/csvsimple.sty +++ b/Master/texmf-dist/tex/latex/csvsimple/csvsimple.sty @@ -1,8 +1,8 @@ -%% The LaTeX package csvsimple - version 1.12 (2014/07/14) +%% The LaTeX package csvsimple - version 1.20 (2016/07/01) %% csvsimple.sty: Simple LaTeX CSV file processing %% %% ------------------------------------------------------------------------------------------- -%% Copyright (c) 2008-2014 by Prof. Dr. Dr. Thomas F. Sturm <thomas dot sturm at unibw dot de> +%% Copyright (c) 2008-2016 by Prof. Dr. Dr. Thomas F. Sturm <thomas dot sturm at unibw dot de> %% ------------------------------------------------------------------------------------------- %% %% This work may be distributed and/or modified under the @@ -18,9 +18,9 @@ %% This work consists of all files listed in README %% \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{csvsimple}[2014/07/14 version 1.12 LaTeX CSV file processing] +\ProvidesPackage{csvsimple}[2016/07/01 version 1.20 LaTeX CSV file processing] -\RequirePackage{pgfkeys,ifthen} +\RequirePackage{pgfkeys,ifthen,etoolbox,shellesc} %---- general @@ -35,13 +35,6 @@ \def\csv@empty{} -\def\csv@addto@macro#1#2{% - \begingroup% - \toks@\expandafter{#1#2}% - \xdef#1{\the\toks@}% - \endgroup% - } - \long\def\csviffirstrow#1#2{% \ifnum\c@csvrow=1% \long\def\csviffirstrow@doit{#1}% @@ -60,12 +53,16 @@ \csvifoddrow@doit% } -\def\csv@and{&} - -\def\csvlinetotablerow{% - \setcounter{csvcol}{0}% - \stepcounter{csvcol}\csv@current@col% - \whiledo{\thecsvcol<\csv@columncount}{\csv@and\stepcounter{csvcol}\csv@current@col}% +\def\csv@assemble@csvlinetotablerow{% + \global\c@csvcol 1\relax% + \xdef\csvlinetotablerow{\expandonce{\csname csvcol\romannumeral\c@csvcol\endcsname}}% + \ifnum\c@csvcol<\csv@columncount\relax% + \loop% + \global\advance\c@csvcol 1\relax% + \xappto\csvlinetotablerow{\noexpand&\expandonce{\csname csvcol\romannumeral\c@csvcol\endcsname}}% + \ifnum\c@csvcol<\csv@columncount\relax\repeat% + \fi% + \csvlinetotablerow% } @@ -91,48 +88,48 @@ \def\csv@breakline@kernel#1{% \ifx\csv@termination#1\let\nextcol=\relax\else% \let\nextcol=\csv@breakline% - \stepcounter{csvcol}% + \global\advance\c@csvcol 1\relax% \def\csv@col@body{#1}% \csv@TrimSpaces\csv@col@body% \csv@TrimBraces\csv@col@body% \toks@\expandafter{\csv@col@body}% - \expandafter\xdef\csname csvcol\roman{csvcol}\endcsname{\the\toks@}% + \expandafter\xdef\csname csvcol\romannumeral\c@csvcol\endcsname{\the\toks@}% \fi% \nextcol% - } +} % comma \def\csv@breakline@A#1,{\csv@breakline@kernel{#1}} \def\csv@scanline@A#1{% - \setcounter{csvcol}{0}% + \global\c@csvcol 0\relax% \csv@breakline#1,\csv@termination,% - } +} % semi colon \def\csv@breakline@B#1;{\csv@breakline@kernel{#1}} \def\csv@scanline@B#1{% - \setcounter{csvcol}{0}% + \global\c@csvcol 0\relax% \csv@breakline#1;\csv@termination;% - } +} % pipe \def\csv@breakline@C#1|{\csv@breakline@kernel{#1}} \def\csv@scanline@C#1{% - \setcounter{csvcol}{0}% + \global\c@csvcol 0\relax% \csv@breakline#1|\csv@termination|% - } +} % tab \catcode`\^^I=12 \def\csv@breakline@D#1^^I{\csv@breakline@kernel{#1}} \def\csv@scanline@D#1{% - \setcounter{csvcol}{0}% + \global\c@csvcol 0\relax% \csv@breakline#1^^I\csv@termination^^I% - } +} \catcode`\^^I=10 % expands a CSV line and scans content @@ -140,7 +137,7 @@ \toks@\expandafter{#1}% \edef\@csv@scanline{\noexpand\csv@scanline{\the\toks@}}% \@csv@scanline% - } +} { \catcode`\"=12% @@ -155,7 +152,7 @@ \immediate\openout\csv@out=\csv@csvsorter@token% \immediate\write\csv@out{\string\makeatletter\string\csv@error{Call of CSV-Sorter failed! Use '-shell-escape' option or check log file '\csv@csvsorter@log'.}{}}% \immediate\closeout\csv@out% - \immediate\write18{\csv@csvsorter@command\space + \ShellEscape{\csv@csvsorter@command\space -c \csv@passivquotes#1\csv@passivquotes\space -l \csv@passivquotes\csv@csvsorter@log\csv@passivquotes\space -t \csv@passivquotes\csv@csvsorter@token\csv@passivquotes\space @@ -178,24 +175,23 @@ %---- the loop -\def\csv@AtEndLoop{\csv@addto@macro\@endloophook} +\def\csv@AtEndLoop{\gappto\@endloophook} \let\@endloophook\csv@empty -\def\csv@current@col{\csname csvcol\roman{csvcol}\endcsname} +\def\csv@current@col{\csname csvcol\romannumeral\c@csvcol\endcsname} % auto head names \def\set@csv@autohead{% \toks0=\expandafter{\csname\csv@current@col\endcsname}% - \toks1=\expandafter{\csname csvcol\roman{csvcol}\endcsname}% + \toks1=\expandafter{\csname csvcol\romannumeral\c@csvcol\endcsname}% \edef\csv@temp{\noexpand\gdef\the\toks0{\the\toks1}\noexpand\csv@AtEndLoop{\noexpand\gdef\the\toks0{}}}% \csv@temp% } - % head names and numbers \def\set@csv@head{% \toks0={\gdef##1}% - \toks1=\expandafter{\csname csvcol\roman{csvcol}\endcsname}% + \toks1=\expandafter{\csname csvcol\romannumeral\c@csvcol\endcsname}% \edef\csv@temp{\noexpand\pgfkeysdef{/csv head/\csv@current@col}{\the\toks0{\the\toks1}\noexpand\csv@AtEndLoop{\the\toks0{}}}}% \csv@temp% \edef\csv@temp{\noexpand\pgfkeysdef{/csv head/\thecsvcol}{\the\toks0{\the\toks1}\noexpand\csv@AtEndLoop{\the\toks0{}}}}% @@ -210,12 +206,12 @@ \else\csv@escanline{\csvline}% \fi% \xdef\csv@columncount{\thecsvcol}% - \setcounter{csvcol}{0}% + \global\c@csvcol 0\relax% \loop% - \stepcounter{csvcol}% + \global\advance\c@csvcol 1\relax% \csv@opt@headtocolumnames% \set@csv@head% - \ifnum\thecsvcol<\csv@columncount\repeat% + \ifnum\c@csvcol<\csv@columncount\repeat% \toks@=\expandafter{\csv@columnnames}% \edef\csv@processkeys{\noexpand\pgfkeys{/csv head/.cd,\the\toks@}}% \csv@processkeys% @@ -225,18 +221,18 @@ % head numbers for no head \def\set@csv@nohead{% \toks0={\gdef##1}% - \toks1=\expandafter{\csname csvcol\roman{csvcol}\endcsname}% + \toks1=\expandafter{\csname csvcol\romannumeral\c@csvcol\endcsname}% \edef\csv@temp{\noexpand\pgfkeysdef{/csv head/\thecsvcol}{\the\toks0{\the\toks1}\noexpand\csv@AtEndLoop{\the\toks0{}}}}% \csv@temp% } % no head line \def\csv@noheadline{% - \setcounter{csvcol}{0}% + \global\c@csvcol 0\relax% \loop% - \stepcounter{csvcol}% + \global\advance\c@csvcol 1\relax% \set@csv@nohead% - \ifnum\thecsvcol<\csv@columncount\repeat% + \ifnum\c@csvcol<\csv@columncount\repeat% \toks@=\expandafter{\csv@columnnames}% \edef\csv@processkeys{\noexpand\pgfkeys{/csv head/.cd,\the\toks@}}% \csv@processkeys% @@ -261,9 +257,9 @@ % check columns \def\csv@checkcolumncount{% - \ifnum\thecsvcol=\csv@columncount% + \ifnum\c@csvcol=\csv@columncount\relax% \csv@checkfilter% - \else + \else% \csv@columncounterror% \fi% } @@ -288,9 +284,10 @@ \let\csv@par=\par % reads and processes a CSV file -\def\csvloop#1{% +\long\def\csvloop#1{% % reset \global\let\@endloophook\csv@empty% + \global\let\csvlinetotablerow\csv@assemble@csvlinetotablerow% % options \csvset{default,every csv,#1}% \csv@preprocss% @@ -403,13 +400,15 @@ head to column names/true/.code={\global\let\csv@opt@headtocolumnames=\set@csv@autohead},% head to column names/false/.code={\global\let\csv@opt@headtocolumnames=\csv@empty},% column count/.gstore in=\csv@columncount,% - filter/.code={% - \def\temp{#1}\toks@=\expandafter{\temp}% - \xdef\csv@iffilter{\noexpand\ifthenelse{\the\toks@}}}, + filter/.code={\gdef\csv@iffilter{\ifthenelse{#1}}}, + filter ifthen/.code={\gdef\csv@iffilter{\ifthenelse{#1}}}, + filter test/.code={\gdef\csv@iffilter{#1}}, + filter expr/.code={\gdef\csv@iffilter{\ifboolexpr{#1}}}, no filter/.code={\csvfilteraccept}, filter reject all/.code={\csvfilterreject}, filter accept all/.code={\csvfilteraccept}, before filter/.gstore in=\csv@prefiltercommand, + full filter/.gstore in=\csv@prefiltercommand, before first line/.gstore in=\csv@prefirstline, before line/.code={\gdef\csv@preline{#1}\pgfkeysalso{before first line=#1}}, after first line/.gstore in=\csv@postfirstline, @@ -483,8 +482,10 @@ no head/.style={head=false}, no check column count/.style={check column count=false}, warn on column count error/.style={on column count error={\csv@warning{>\thecsvcol< instead of >\csv@columncount< columns for input line >\thecsvinputline< of file >\csv@ppfilename<}}}, - filter equal/.style 2 args={filter=\equal{#1}{#2}}, - filter not equal/.style 2 args={filter=\not\equal{#1}{#2}}, + filter equal/.style 2 args={filter ifthen=\equal{#1}{#2}}, + filter not equal/.style 2 args={filter ifthen=\not\equal{#1}{#2}}, + filter strcmp/.style 2 args={filter test=\ifcsvstrcmp{#1}{#2}}, + filter not strcmp/.style 2 args={filter test=\ifcsvnotstrcmp{#1}{#2}}, tabular/.style={ @table={\csv@pretable\begin{tabular}{#1}\csv@tablehead}{\csv@tablefoot\end{tabular}\csv@posttable}, late after line=\\}, @@ -727,3 +728,51 @@ \def\csvnames#1#2{\csvset{#1/.style={column names={#2}}}} +% string comparison + +\newrobustcmd{\ifcsvstrequal}[2]{% + \begingroup% + \protected@edef\csv@tempa{#1}% + \protected@edef\csv@tempb{#2}% + \edef\csv@tempa{#1}% + \edef\csv@tempb{#2}% + \ifx\csv@tempa\csv@tempb% + \aftergroup\@firstoftwo% + \else% + \aftergroup\@secondoftwo% + \fi% + \endgroup% +}% + +\newrobustcmd{\ifcsvprostrequal}[2]{% + \begingroup% + \protected@edef\csv@tempa{#1}% + \protected@edef\csv@tempb{#2}% + \ifx\csv@tempa\csv@tempb% + \aftergroup\@firstoftwo% + \else% + \aftergroup\@secondoftwo% + \fi% + \endgroup% +}% + +\AtBeginDocument{% + \ifdefined\pdfstrcmp% + \let\csv@strcmp\pdfstrcmp% + \else\ifdefined\pdf@strcmp% + \let\csv@strcmp\pdf@strcmp% + \fi\fi% + \ifdefined\csv@strcmp% + \newrobustcmd{\ifcsvstrcmp}[2]{% + \ifnum\csv@strcmp{#1}{#2}=\z@\relax% + \expandafter\@firstoftwo% + \else% + \expandafter\@secondoftwo% + \fi% + }% + \else% + \let\ifcsvstrcmp\ifcsvstrequal% + \fi% +} + +\newrobustcmd{\ifcsvnotstrcmp}[4]{\ifcsvstrcmp{#1}{#2}{#4}{#3}} |