From 136f39c4716d4adccfd552ba03e269e58b8d7a69 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Thu, 8 Nov 2012 23:07:15 +0000 Subject: csvsimple (8nov12) git-svn-id: svn://tug.org/texlive/trunk@28211 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/csvsimple/CHANGES | 9 ++- Master/texmf-dist/doc/latex/csvsimple/README | 2 +- .../doc/latex/csvsimple/csvsimple-example.pdf | Bin 72286 -> 72286 bytes .../doc/latex/csvsimple/csvsimple-example.tex | 2 +- .../texmf-dist/doc/latex/csvsimple/csvsimple.pdf | Bin 607836 -> 637468 bytes .../texmf-dist/doc/latex/csvsimple/csvsimple.tex | 73 +++++++++++++++++---- .../texmf-dist/tex/latex/csvsimple/csvsimple.sty | 24 ++++--- 7 files changed, 87 insertions(+), 23 deletions(-) diff --git a/Master/texmf-dist/doc/latex/csvsimple/CHANGES b/Master/texmf-dist/doc/latex/csvsimple/CHANGES index a0ad80b3808..12fa1020e44 100644 --- a/Master/texmf-dist/doc/latex/csvsimple/CHANGES +++ b/Master/texmf-dist/doc/latex/csvsimple/CHANGES @@ -1,4 +1,4 @@ -%% The LaTeX package csvsimple - version 1.05 (2012/03/12) +%% The LaTeX package csvsimple - version 1.06 (2012/11/08) %% %% ------------------------------------------------------------------------------------------- %% Copyright (c) 2008-2012 by Prof. Dr. Dr. Thomas F. Sturm @@ -51,3 +51,10 @@ version 1.05 (2012/03/12): - key nofilter renamed to 'no filter' and 'nohead' to 'no head' (the old names are kept as deprecated key names) +version 1.06 (2012/11/08): +- implementation for line breaking changed from full macro expansion to + token expansion. This allows quite arbitrary macro code inside the data. + Note that this may be a breaking change if your application expects + expanded column values. +- option values added for \csvautotabular and \csvautolongtable + diff --git a/Master/texmf-dist/doc/latex/csvsimple/README b/Master/texmf-dist/doc/latex/csvsimple/README index 1f730eaa61a..840bef3c6aa 100644 --- a/Master/texmf-dist/doc/latex/csvsimple/README +++ b/Master/texmf-dist/doc/latex/csvsimple/README @@ -1,4 +1,4 @@ -%% The LaTeX package csvsimple - version 1.05 (2012/03/12) +%% The LaTeX package csvsimple - version 1.06 (2012/11/08) %% %% ------------------------------------------------------------------------------------------- %% Copyright (c) 2008-2012 by Prof. Dr. Dr. Thomas F. Sturm diff --git a/Master/texmf-dist/doc/latex/csvsimple/csvsimple-example.pdf b/Master/texmf-dist/doc/latex/csvsimple/csvsimple-example.pdf index f1848b15ce7..b9fc81d57b7 100644 Binary files a/Master/texmf-dist/doc/latex/csvsimple/csvsimple-example.pdf and b/Master/texmf-dist/doc/latex/csvsimple/csvsimple-example.pdf differ diff --git a/Master/texmf-dist/doc/latex/csvsimple/csvsimple-example.tex b/Master/texmf-dist/doc/latex/csvsimple/csvsimple-example.tex index dcf284ed009..ac2887915e5 100644 --- a/Master/texmf-dist/doc/latex/csvsimple/csvsimple-example.tex +++ b/Master/texmf-dist/doc/latex/csvsimple/csvsimple-example.tex @@ -1,4 +1,4 @@ -%% The LaTeX package csvsimple - version 1.05 (2012/03/12) +%% The LaTeX package csvsimple - version 1.06 (2012/11/08) %% csvsimple-example.tex: an example for csvsimple %% %% ------------------------------------------------------------------------------------------- diff --git a/Master/texmf-dist/doc/latex/csvsimple/csvsimple.pdf b/Master/texmf-dist/doc/latex/csvsimple/csvsimple.pdf index 38a992ea27e..f5320a67f79 100644 Binary files a/Master/texmf-dist/doc/latex/csvsimple/csvsimple.pdf and b/Master/texmf-dist/doc/latex/csvsimple/csvsimple.pdf differ diff --git a/Master/texmf-dist/doc/latex/csvsimple/csvsimple.tex b/Master/texmf-dist/doc/latex/csvsimple/csvsimple.tex index 96ac0ffeb56..6d9ea7e7b6c 100644 --- a/Master/texmf-dist/doc/latex/csvsimple/csvsimple.tex +++ b/Master/texmf-dist/doc/latex/csvsimple/csvsimple.tex @@ -1,5 +1,5 @@ % \LaTeX-Main\ -%% The LaTeX package csvsimple - version 1.05 (2012/03/12) +%% The LaTeX package csvsimple - version 1.06 (2012/11/08) %% csvsimple.sty: Simple LaTeX CSV file processing %% %% ------------------------------------------------------------------------------------------- @@ -72,8 +72,8 @@ pdfkeywords={csv file, comma separated values, key value syntax} } -\def\version{1.05}% -\def\datum{2012/03/12}% +\def\version{1.06}% +\def\datum{2012/11/08}% \makeindex @@ -109,7 +109,7 @@ This processing is controlled by key value assignments according to the syntax of |pgfkeys| \cite{tantau:2010c}. Sample applications of the package are tabular lists, serial letters, and charts. -An alternative to |csvsimple| is the |datatool| package \cite{talbot:2009a} +An alternative to |csvsimple| is the |datatool| package \cite{talbot:2012a} which provides considerably more functions like exchange of separator and delimiter symbols or sorting of data. |csvsimple| has a different approach for the user interface and @@ -356,27 +356,36 @@ is useless for |\csvreader|. \end{docCommand} \clearpage -\begin{docCommand}{csvautotabular}{\marg{file name}} +\begin{docCommand}{csvautotabular}{\oarg{options}\marg{file name}} |\csvautotabular| is an abbreviation for the application of the option key - \refKey{/csv/autotabular}. + \refKey{/csv/autotabular} together with other \meta{options} to \refCom{csvloop}. This macro reads the whole CSV file denoted by \meta{file name} with an automated formatting. \begin{dispExample} \csvautotabular{grade.csv} \end{dispExample} +\begin{dispExample} +\csvautotabular[filter equal={\csvcoliv}{f}]{grade.csv} +\end{dispExample} \end{docCommand} -\begin{docCommand}{csvautolongtable}{\marg{file name}} +\begin{docCommand}{csvautolongtable}{\oarg{options}\marg{file name}} |csvautolongtable| is an abbreviation for the application of the option key - \refKey{/csv/autolongtable}. + \refKey{/csv/autolongtable} together with other \meta{options} to \refCom{csvloop}. This macro reads the whole CSV file denoted by \meta{file name} with an automated formatting. For application, the package |longtable| is required which has to be loaded in the preamble. +\begin{dispListing} +\csvautolongtable{grade.csv} +\end{dispListing} +\csvautolongtable{grade.csv} \end{docCommand} +\clearpage + \begin{docCommand}{csvset}{\marg{options}} Sets \meta{options} for every following \refCom{csvreader} and \refCom{csvloop}. For example, this command may @@ -929,7 +938,8 @@ introduced. \csvreader[head to column names]{address.csv}{}{% \begin{tcolorbox}[colframe=DarkGray,colback=White,arc=0mm,width=(\linewidth-2pt)/2, - before=,after=\hfill,title={Letter to \name},fonttitle=\bfseries] + equal height group=letter,before=,after=\hfill,fonttitle=\bfseries, + adjusted title={Letter to \name}] \ifthenelse{\equal{\degree}{}}{\ifmale{Mr.}{Ms.}}{\degree}~\givenname~\name\\ \street\\\zip~\location \tcblower @@ -1050,6 +1060,45 @@ Every item is piled upon the appropriate stack. \end{dispExample} +\clearpage +\subsection{Macro code inside the data}% + +If needed, the data file may contain macro code. Note that the first character +of a data line is not allowed to be the backslash '|\|'. + +%-- file embedded for simplicity -- +\begin{tcbverbatimwrite}{macrodata.csv} +type,description,content +M,A nice \textbf{formula}, $\displaystyle \int\frac{1}{x} = \ln|x|+c$ +G,A \textcolor{red}{colored} ball, {\tikz \shadedraw [shading=ball] (0,0) circle (.5cm);} +M,\textbf{Another} formula, $\displaystyle \lim\limits_{n\to\infty} \frac{1}{n}=0$ +\end{tcbverbatimwrite} +%-- end embedded file -- + +\csvlisting{macrodata} + +Firstly, we survey the file content using +|\csvautotabular|. + +\begin{dispExample} +\csvautotabular{macrodata.csv} +\end{dispExample} + + +\begin{dispExample} +\csvstyle{my enumerate}{head to column names, + before reading=\begin{enumerate},after reading=\end{enumerate}} + +\csvreader[my enumerate]{macrodata.csv}{}{% + \item \description:\par\content} + +\bigskip +Now, formulas only: +\csvreader[my enumerate,filter equal={\type}{M}]{macrodata.csv}{}{% + \item \description:\qquad\content} +\end{dispExample} + + % Actually, it is not a good idea to include the references like this! % Do not follow this bad example ... \begin{tcbverbatimwrite}{\jobname.bib} @@ -1072,11 +1121,11 @@ Every item is piled upon the appropriate stack. language = {english} } -@manual{talbot:2009a, +@manual{talbot:2012a, author = {Nicola L. C. Talbot}, - title = {datatool v 2.03: Databases and data manipulation}, + title = {datatool v 2.11: Databases and data manipulation}, url = {http://mirror.ctan.org/macros/latex/contrib/datatool/datatool.pdf}, - date = {2009-11-15}, + date = {2012-09-25}, } \end{tcbverbatimwrite} diff --git a/Master/texmf-dist/tex/latex/csvsimple/csvsimple.sty b/Master/texmf-dist/tex/latex/csvsimple/csvsimple.sty index 545e15e638f..54a54d36c3a 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.05 (2012/03/12) +%% The LaTeX package csvsimple - version 1.06 (2012/11/08) %% csvsimple.sty: Simple LaTeX CSV file processing %% %% ------------------------------------------------------------------------------------------- -%% Copyright (c) 2008-2011 by Prof. Dr. Dr. Thomas F. Sturm +%% Copyright (c) 2008-2012 by Prof. Dr. Dr. Thomas F. Sturm %% ------------------------------------------------------------------------------------------- %% %% This work may be distributed and/or modified under the @@ -18,7 +18,7 @@ %% This work consists of all files listed in README %% \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{csvsimple}[2012/03/12 version 1.05 LaTeX CSV file processing] +\ProvidesPackage{csvsimple}[2012/11/08 version 1.06 LaTeX CSV file processing] \RequirePackage{pgfkeys,ifthen} @@ -89,8 +89,9 @@ \ifx\csv@termination#1\let\nextcol=\relax\else% \let\nextcol=\csv@breakline% \stepcounter{csvcol}% - \edef\csv@col@body{#1}\TrimSpaces\csv@col@body% - \expandafter\xdef\csname csvcol\roman{csvcol}\endcsname{\csv@col@body}% + \def\csv@col@body{#1}\TrimSpaces\csv@col@body% + \toks@\expandafter{\csv@col@body}% + \expandafter\xdef\csname csvcol\roman{csvcol}\endcsname{\the\toks@}% \fi% \nextcol% } @@ -103,7 +104,8 @@ % expands a CSV line and scans content \def\csv@escanline#1{% - \edef\@csv@scanline{\noexpand\csv@scanline{#1}}% + \toks@\expandafter{#1}% + \edef\@csv@scanline{\noexpand\csv@scanline{\the\toks@}}% \@csv@scanline% } @@ -434,9 +436,15 @@ } -\def\csvautotabular#1{\csvloop{autotabular={#1}}} +\long\def\csv@autotabular[#1]#2{\csvloop{autotabular={#2},#1}} -\def\csvautolongtable#1{\csvloop{autolongtable={#1}}} +\def\csvautotabular{% + \@ifnextchar[{\csv@autotabular}{\csv@autotabular[]}} + +\long\def\csv@autolongtable[#1]#2{\csvloop{autolongtable={#2},#1}} + +\def\csvautolongtable{% + \@ifnextchar[{\csv@autolongtable}{\csv@autolongtable[]}} \def\csvstyle#1#2{\csvset{#1/.style={#2}}} -- cgit v1.2.3