我有一个包含 796 行和 20 列的 .csv 文件,构建文件需要 15 分钟以上,而我正在从 .csv 读取文件,我们可以做些什么来快速构建以获得相同的结果吗?我正在使用软件包、、、、、、、、、和。您graphicx
的评论非常宝贵。我无法在 csv 文件中写入所有行。谢谢。这是我的MWEbooktabs
xstring
datatool
xintexpr
longtable
minted
multirow
colortbl
tcolorbox
xcolor
\documentclass[10.0pt,legalpaper,landscape]{article}
\usepackage[top=0.5cm,bottom=1.4cm,left=2cm,right=0.1cm]{geometry}
\usepackage[table]{xcolor}
\usepackage[all]{tcolorbox}
\usepackage[english]{babel}
\usepackage{graphicx,booktabs,xstring,datatool,xintexpr,longtable,minted} %for including eps graphics
\usepackage{multirow,colortbl}
\usepackage{filecontents}
\renewcommand{\dtldisplaystarttab}{\toprule}
\renewcommand{\dtldisplayafterhead}{\midrule}
\renewcommand{\dtldisplayendtab}{\\\bottomrule}
\usepackage{array}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\begin{filecontents*}{MemberSummary.csv}
Unique ID,Name,Gender,Blood Group,Relationship with Head,Date of Birth,Baptised,Date of Baptism,Baptized By,Death,Date of Death,Transfer,Date of Transfer,Phone No.,Suspension,Reason,Areawise,Educational Qualification,Ocupation,Youth,Women,Signature
ABC0001,Name 1,M,AB+,Head,03/05/1933,Y,19/06/1946,Baptized 1,N,,N,,1234567895,,,Area 3,Cl-X,Retd. G.Sw,Y,Y,
,Name 2,F,AB+,Wife,,Y,17/07/1960,Baptized 2,N,,N,,1234567896,,,Area 3,,House wife,N,N,
,Name 3,M,AB+,son,,Y,26/02/1980,Baptized 3,N,,N,,1234567897,,,Area 3,Cl-X,,N,N,
,Name 4,F,AB+,Daughter in law,,Y,27/06/1985,Baptized 4,N,,N,,1234567898,,,Area 3,Cl-VIII,House Wife,Y,Y,
,Name 5,F,AB+,Grand Daughter,,N,,Baptized 5,N,,N,,1234567899,,,Area 3,Cl-II,Student,Y,Y,
,Name 6,F,AB+,daughter ,,Y,,Baptized 6,N,,Y,,1234567900,,,Area 3,,,Y,Y,
,Name 7,M,AB+,Son,,Y,06/04/94,Baptized 7,N,,N,,1234567901,,,Area 3,B.A,Music Teacher,Y,Y,
,Name 8,M,A+,Son,,Y,30/04/1996 ,Baptized 8,N,,N,,1234567902,,,Area 3,B.A,Office Asst.,Y,Y,
ABC0002,Name 9,F,A-,Head,,Y,17/04/1990 ,Baptized 9,N,,N,,1234567903,,,Area 4,Matriculate,Service,Y,Y,
,Name 10,M,A-,Father,,Y,,Baptized 10,Y,02/12/2007,,,1234567904,,,Area 4,,,Y,Y,
,Name 11,M,A-,Son ,,Y,11/06/08,Baptized 11,N,,N,,1234567905,,,Area 4,H.S. Passed,Student,Y,Y,
,Name 12,M,A-,Son ,,Y,,Baptized 12,N,,N,,1234567906,,,Area 4,Cl-VIII,Student,Y,Y,
ABC0003 ,Name 13,M,A-,Head,,Y,,Baptized 13,N,,N,,1234567907,,,Area 1,Matriculate,Service,Y,Y,
,Name 14,F,A-,Wife,,Y,,Baptized 14,N,,N,,1234567908,,,Area 1,Graduate,Teacher,Y,Y,
,Name 15,F,A-,Daughter,,Y,,Baptized 15,N,,N,,1234567909,,,Area 1,Cl-IX,Student,Y,Y,
ABC0004,Name 16,M,A-,Head,,Y,1935,Baptized 16,N,,N,,1234567910,,,Area 2,Cl-X,Retired,Y,Y,
,Name 17,M,A-,Father,,Y,,Baptized 17,Y,died ,,,1234567911,,,Area 2,,,Y,Y,
,Name 18,F,A-,Mother,,Y,,Baptized 18,Y,died ,,,1234567912,,,Area 2,,,Y,Y,
,Name 19,F,A-,Wife,,Y,,Baptized 19,N,,N,,1234567913,,,Area 2,,House wife,Y,Y,
,Name 20,M,A-,Son,,Y,,Baptized 20,,,,,1234567914,Y,,Area 2,M.A pol.sc,Business,Y,Y,
,Name 21,F,A-,Daughter in Law,,Y,,Baptized 21,N,,N,,1234567915,,,Area 2,Under Graduate,Service,Y,Y,
,Name 22,M,A-,Grand son,,Y,,Baptized 22,N,,N,,1234567916,,,Area 2,M.A,Student,N,N,
,Name 23,M,A-,Grand son,,Y,,Baptized 23,N,,N,,1234567917,,,Area 2,B.A,Student,N,N,
,Name 24,F,A-,daughter ,,Y,,Baptized 24,,,,,1234567918,Y,,Area 2,,,N,N,
,Name 25,F,A-,Daughter in Law,,Y,,Baptized 25,N,,Y,,1234567919,,,Area 2,Under Graduate,Srevice,N,N,
ABC0005,Name 26,M,AB+,Head,,Y,,Baptized 26,N,,N,,1234567920,,,Area 5,Graduate,Business,N,N,
,Name 27,F,A+,Wife,,Y,,Baptized 27,N,,N,,1234567921,,,Area 5,"M.A, B.ed",Lecturer,N,N,
,Name 28,F,A+,Daughter,,N,,Baptized 28,N,,N,,1234567922,,,Area 5,Student,Student,N,N,
,Name 29,F,B+,Daughter,,N,,Baptized 29,N,,N,,1234567923,,,Area 5,,,N,N,
,Name 30,M,B+,Son,,N,,Baptized 30,N,,N,,1234567924,,,Area 5,,,N,N,
ABC0006,Name 31,F,B+,Head ,,Y,,Baptized 31,N,,N,,1234567925,,,Area 3,Cl-VII,House wife,N,N,
,Name 32,M,B+,Father,,Y,,Baptized 32,Y,22-1-2014,,,1234567926,,,Area 3,Cl-VII,Business,N,N,
,Name 33,M,B+,Son,,Y,,Baptized 33,N,,N,,1234567927,,,Area 3,Cl-X,,N,N,
,Name 34,F,B+,Daughter,,Y,,Baptized 34,N,,N,,1234567928,,,Area 3,Matriculate,,Y,Y,
,Name 35,F,B+,daughter ,,Y,,Baptized 35,N,,Y,,1234567929,,,Area 3,,,N,N,
ABC0007,Name 36,M,O-,Head,,Y,,Baptized 36,N,,N,,1234567930,,,Area 6,B.A,Bussiness,Y,Y,
,Name 37,F,O+,Wife,,Y,,Baptized 37,N,,N,,1234567931,,,Area 6,,House wife,Y,Y,
,Name 38,M,B-,Son,,Y,,Baptized 38,N,,N,,1234567932,,,Area 6,H.S. Passed,,Y,Y,
,Name 39,F,O-,Daughter in law,,Y,,Baptized 39,N,,N,,1234567933,,,Area 6,Cl-X,,Y,Y,
,Name 40,F,O+,grand daughter ,,N,,Baptized 40,N,,N,,1234567934,,,Area 6,,,Y,Y,
,Name 41,M,O+,Son ,,Y,,Baptized 41,N,,N,,1234567935,,,Area 6,H.S. Passed,,Y,Y,
,Name 42,M,O+,Son,,N,,Baptized 42,N,,N,,1234567936,,,Area 6,Cl-VII,,Y,Y,
\end{filecontents*}
% read in text file to database
\DTLloaddb{death}{MemberSummary.csv}
% set up counters
\newcounter{Female} % Female Membership Counter
\newcounter{Male} % Male Membership Counter
\newcounter{FemaleD} % Female Death counter
\newcounter{MaleD} % Male Death counter
\newcounter{Total} % Total Membership counter
\newcounter{TotalD} % Total Death counter
\newcounter{MaleB} % Baptised Male counter
\newcounter{FemaleB} % Baptised female counter
\newcounter{MaleU} % UnBaptised Male counter
\newcounter{FemaleU} % UnBaptised female counter
\newcounter{TotalU} % Total Unbaptised Member counter
\newcounter{TotalB} % Total Baptised counter
\newcounter{MaleT} % Total male transfer
\newcounter{FemaleT} % Total female transfer
\newcounter{TotalT} % Total transfer
\newcounter{MaleE} % Existing male members
\newcounter{FemaleE} % Existing female members
\newcounter{TotalE} % Existing total members
\newcounter{MaleBE} % Existing male baptised
\newcounter{FemaleBE} % Existing female baptised
\newcounter{TotalBE} % Existing total baptised
%\newcounter{SerialI} % Serial Numbering Iteration according to name present
\newcounter{Serial} % Serial Numbering according to name present
\newcounter{SerialN} % Serial Numbering
\newcounter{A} % Coding for Area 1
\newcounter{B} % Coding for Area 2
\newcounter{C} % Coding for Area 3
\newcounter{D} % Coding for Area 4
\newcounter{E} % Coding for Area 5
\newcounter{F} % Coding for Area 6
\newcounter{AT} % Coding for Area 1 total members
\newcounter{BT} % Coding for Area 2 total members
\newcounter{CT} % Coding for Area 3 total members
\newcounter{DT} % Coding for Area 4 total members
\newcounter{ET} % Coding for Area 5 total members
\newcounter{FT} % Coding for Area 6 total members
\newcounter{AreaT} % Total areawise members
\newcounter{AH} % Coding for Area 1 Total Household
\newcounter{BH} % Coding for Area 2 Total Household
\newcounter{CH} % Coding for Area 3 Total Household
\newcounter{DH} % Coding for Area 4 Total Household
\newcounter{EH} % Coding for Area 5 Total Household
\newcounter{FH} % Coding for Area 6 Total Household
%%%%
\newcounter{GA} % Coding for Area 1
\newcounter{GB} % Coding for Area 2
\newcounter{GC} % Coding for Area 3
\newcounter{GD} % Coding for Area 4
\newcounter{GE} % Coding for Area 5
\newcounter{GF} % Coding for Area 6
\newcounter{GAH} % Coding for Area 1 household
\newcounter{GBH} % Coding for Area 2 household
\newcounter{GCH} % Coding for Area 3 household
\newcounter{GDH} % Coding for Area 4 household
\newcounter{GEH} % Coding for Area 5 household
\newcounter{GFH} % Coding for Area 6 household
\newcounter{TotalG} % Counter for total existing member
\newcounter{TotalGH} % Counter for total house existing
\newcounter{TotalUE} % counter for existing unbaptise
\newcounter{TotalUME} % counter for unbaptised existing male
\newcounter{TotalUFE} % counter for unbaptised existing female
\newcounter{FSus} % counter for female suspension
\newcounter{MSus} % counter for male suspension
\newcounter{TotalSus} % counter fot total suspension
%% Counter for blood group
\newcounter{Ap} % counter for blood group A+
\newcounter{Am} % counter for blood group A+
\newcounter{Bp} % counter for blood group B+
\newcounter{Bm} % counter for blood group B-
\newcounter{Op} % counter for blood group O+
\newcounter{Om} % counter for blood group O-
\newcounter{ABp} % counter for blood group AB+
\newcounter{ABm} % counter for blood group AB-
\newcounter{BloodT} % counter for total blood group
\makeatletter\let\expandableinput\@@input\makeatother
\begin{document}
%\DeclareTCBListing{mybox}{ s O{} m }{%
%colback=red!5!white,colframe=red!75!black,fonttitle=\bfseries,IfBooleanTF={#1}{listing side text}{text side listing},title=#3,#2}
\DeclareTColorBox{mybox}{ o }{colframe=white,colback=gray!15!white,
IfValueTF={#1}{title={\flqq #1\frqq},fonttitle=\bfseries}{}}
%\arrayrulewidth=0.7pt % change thickness of vertical and horizontal lines of a table
\begin{longtable}{|C{0.5cm}|C{1.5cm}|L{4.7cm}|C{0.35cm}|C{1.8cm}|C{0.6cm}|C{0.35cm}|C{1.8cm}|L{4.1cm}|C{0.35cm}|C{1.8cm}|C{0.3cm}|C{1.8cm}|l|C{3.7cm}|}
%\toprule
\hline
\rowcolor{green!20}\bf\rotatebox{90}{Sl.~No.} & \bf{Unique ID} & \hfill\bf{Name}\hfill~ & \bf\rotatebox{90}{Gender}& \bf{Date\newline of\newline Birth}& \bf\rotatebox{90}{Blood Group} & \bf\rotatebox{90}{Baptised}&\bf{Date\newline of\newline Baptism} & \hfill\bf{Baptized By}\hfill~ & \bf\rotatebox{90}{Death}& \bf{Date\newline of\newline Death} & \bf\rotatebox{90}{Transfer}& \bf\rotatebox{90}{Phone No.} & \bf{\hspace{6mm}Areawise} & \bf{Signature}\\\hline \endhead
\DTLforeach*{death}{\id=Unique ID,\name=Name,\g=Gender,\bg=Blood Group,\d=Death,\b=Baptised,\tr=Transfer,\phone=Phone No.,\a=Areawise,\DOB=Date of Birth,\DOBap=Date of Baptism,\by=Baptized By,\DOD=Date of Death}{% build table
\DTLiffirstrow{}{\\\hline} %
% add \midrule before first data row
%\DTLiffirstrow{\\\midrule\endhead}{\\}
%
\IfStrEq{\g}{F}{% check if female
\stepcounter{Female}% add 1 to counter
\IfStrEq{\d}{Y}{\stepcounter{FemaleD}}{}% if also dead, add 1 to that counter
}{%
\stepcounter{Male}% similar for male
\IfStrEq{\d}{Y}{\stepcounter{MaleD}}{}%
}%
\IfStrEq{\g}{F}{% check if female
\IfStrEq{\b}{Y}{\stepcounter{FemaleB}}{\stepcounter{FemaleU}}% if also dead, add 1 to that counter
}{%
\IfStrEq{\b}{Y}{\stepcounter{MaleB}}{\stepcounter{MaleU}}%
}%
\IfStrEq{\g}{F}{% check if female
\IfStrEq{\d}{N}{\IfStrEq{\tr}{Y}{\stepcounter{FemaleT}}}{}% if also dead, add 1 to that counter
}{%
\IfStrEq{\d}{N}{\IfStrEq{\tr}{Y}{\stepcounter{MaleT}}}{}%
}%
\IfStrEq{\g}{F}{\IfStrEq{\b}{Y}{\IfStrEq{\d}{N}{\IfStrEq{\tr}{N}{\stepcounter{FemaleBE}}{}}{}}{}}{}
\IfStrEq{\g}{M}{\IfStrEq{\b}{Y}{\IfStrEq{\d}{N}{\IfStrEq{\tr}{N}{\stepcounter{MaleBE}}{}}{}}{}}{}
\IfStrEq{\a}{Area 1}{\stepcounter{A}}{}
\IfStrEq{\a}{Area 2}{\stepcounter{B}}{}
\IfStrEq{\a}{Area 3}{\stepcounter{C}}{}
\IfStrEq{\a}{Area 4}{\stepcounter{D}}{}
\IfStrEq{\a}{Area 5}{\stepcounter{E}}{}
\IfStrEq{\a}{Area 6}{\stepcounter{F}}{}
%% Coding for Areawise Total Household
\IfStrEq{\a}{Area 1}{\IfBeginWith{\id}{ABC}{\stepcounter{AH}}{}}{}
\IfStrEq{\a}{Area 2}{\IfBeginWith{\id}{ABC}{\stepcounter{BH}}{}}{}
\IfStrEq{\a}{Area 3}{\IfBeginWith{\id}{ABC}{\stepcounter{CH}}{}}{}
\IfStrEq{\a}{Area 4}{\IfBeginWith{\id}{ABC}{\stepcounter{DH}}{}}{}
\IfStrEq{\a}{Area 5}{\IfBeginWith{\id}{ABC}{\stepcounter{EH}}{}}{}
\IfStrEq{\a}{Area 6}{\IfBeginWith{\id}{ABC}{\stepcounter{FH}}{}}{}
\IfSubStr{\id}{ABC}{\stepcounter{Serial}}{}
%\setcounter{Serial}{\numexpr\value{SerialI}\relax}
%\IfInteger{\theSerial}{\stepcounter{SerialNo}}{}
\IfInteger{\theSerial}{\stepcounter{SerialN}}{}
\IfStrEq{\d}{Y}{\IfInteger{\theSerial}{\noindent\raise.5em\vbox{\cellcolor{red!20}\theSerialN} & \cellcolor{red!20}\id & \cellcolor{red!20}\name & \cellcolor{red!20}\g & \cellcolor{red!20}\DOB & \cellcolor{red!20}\bg & \cellcolor{red!20}\b & \cellcolor{red!20}\DOBap & \cellcolor{red!20}\by & \cellcolor{red!20}\d & \cellcolor{red!20}\DOD & \cellcolor{red!20}\tr & \cellcolor{red!20}\phone & \cellcolor{red!20}\a & \cellcolor{red!20} }{}}{\IfStrEq{\tr}{Y}{\IfInteger{\theSerial}{\noindent\raise.5em\vbox{\cellcolor{blue!20}\theSerialN} & \cellcolor{blue!20}\id & \cellcolor{blue!20}\name & \cellcolor{blue!20}\g & \cellcolor{blue!20}\DOB & \cellcolor{blue!20}\bg & \cellcolor{blue!20}\b & \cellcolor{blue!20}\DOBap & \cellcolor{blue!20}\by & \cellcolor{blue!20}\d & \cellcolor{blue!20}\DOD & \cellcolor{blue!20}\tr & \cellcolor{blue!20}\phone & \cellcolor{blue!20}\a & \cellcolor{blue!20} }{}}{\IfInteger{\theSerial}{
\noindent\raise.5em\vbox{\theSerialN} & \id & \name & \g &\DOB & \bg & \b &\DOBap & \by & \d &\DOD & \tr & \phone & \a & }{}}}
}
\\\hline
\end{longtable}
%\end{center}
%\end{minipage}
%\begin{minipage}{5mm}
%\end{minipage}\hfill\hfill
\newpage
\pagenumbering{gobble}
%\KOMAoptions{paper=a4,pagesize}
%\recalctypearea
%% Coding for existing household and existing members
\DTLforeach*{death}{\id=Unique ID,\name=Name,\g=Gender,\bg=Blood Group,\d=Death,\b=Baptised,\tr=Transfer,\a=Areawise, \s=Suspension}{
%% Set values for area existing member
%%set values for existing members
\IfStrEq{\d}{N}{\IfStrEq{\tr}{N}{\IfStrEq{\a}{Area 1}{\stepcounter{GA}}{}}{}}{}
\IfStrEq{\d}{N}{\IfStrEq{\tr}{N}{\IfStrEq{\a}{Area 2}{\stepcounter{GB}}{}}{}}{}
\IfStrEq{\d}{N}{\IfStrEq{\tr}{N}{\IfStrEq{\a}{Area 3}{\stepcounter{GC}}{}}{}}{}
\IfStrEq{\d}{N}{\IfStrEq{\tr}{N}{\IfStrEq{\a}{Area 4}{\stepcounter{GD}}{}}{}}{}
\IfStrEq{\d}{N}{\IfStrEq{\tr}{N}{\IfStrEq{\a}{Area 5}{\stepcounter{GE}}{}}{}}{}
\IfStrEq{\d}{N}{\IfStrEq{\tr}{N}{\IfStrEq{\a}{Area 6}{\stepcounter{GF}}{}}{}}{}
%%set values for existing household number of each areawise
\IfStrEq{\id}{}{}{\IfStrEq{\d}{N}{\IfStrEq{\tr}{N}{\IfStrEq{\a}{Area 1}{\stepcounter{GAH}}{}}{}}{}}
\IfStrEq{\id}{}{}{\IfStrEq{\d}{N}{\IfStrEq{\tr}{N}{\IfStrEq{\a}{Area 2}{\stepcounter{GBH}}{}}{}}{}}
\IfStrEq{\id}{}{}{\IfStrEq{\d}{N}{\IfStrEq{\tr}{N}{\IfStrEq{\a}{Area 3}{\stepcounter{GCH}}{}}{}}{}}
\IfStrEq{\id}{}{}{\IfStrEq{\d}{N}{\IfStrEq{\tr}{N}{\IfStrEq{\a}{Area 4}{\stepcounter{GDH}}{}}{}}{}}
\IfStrEq{\id}{}{}{\IfStrEq{\d}{N}{\IfStrEq{\tr}{N}{\IfStrEq{\a}{Area 5}{\stepcounter{GEH}}{}}{}}{}}
\IfStrEq{\id}{}{}{\IfStrEq{\d}{N}{\IfStrEq{\tr}{N}{\IfStrEq{\a}{Area 6}{\stepcounter{GFH}}{}}{}}{}}
%% set values for suspension from church
\IfStrEq{\g}{F}{\IfStrEq{\s}{Y}{\stepcounter{FSus}}{}}{}
\IfStrEq{\g}{M}{\IfStrEq{\s}{Y}{\stepcounter{MSus}}{}}{}
%% set values for blood group members
\IfStrEq{\s}{Y}{\IfStrEq{\bg}{A+}{\stepcounter{Ap}}{}}{\IfStrEq{\d}{N}{\IfStrEq{\tr}{N}{\IfStrEq{\bg}{A+}{\stepcounter{Ap}}{}}{}}{} }
\IfStrEq{\s}{Y}{\IfStrEq{\bg}{A-}{\stepcounter{Am}}{}}{\IfStrEq{\d}{N}{\IfStrEq{\tr}{N}{\IfStrEq{\bg}{A-}{\stepcounter{Am}}{}}{}}{} }
\IfStrEq{\s}{Y}{\IfStrEq{\bg}{B+}{\stepcounter{Bp}}{}}{\IfStrEq{\d}{N}{\IfStrEq{\tr}{N}{\IfStrEq{\bg}{B+}{\stepcounter{Bp}}{}}{}}{} }
\IfStrEq{\s}{Y}{\IfStrEq{\bg}{B-}{\stepcounter{Bm}}{}}{\IfStrEq{\d}{N}{\IfStrEq{\tr}{N}{\IfStrEq{\bg}{B-}{\stepcounter{Bm}}{}}{}}{} }
\IfStrEq{\s}{Y}{\IfStrEq{\bg}{O+}{\stepcounter{Op}}{}}{\IfStrEq{\d}{N}{\IfStrEq{\tr}{N}{\IfStrEq{\bg}{O+}{\stepcounter{Op}}{}}{}}{} }
\IfStrEq{\s}{Y}{\IfStrEq{\bg}{O-}{\stepcounter{Om}}{}}{\IfStrEq{\d}{N}{\IfStrEq{\tr}{N}{\IfStrEq{\bg}{O-}{\stepcounter{Om}}{}}{}}{} }
\IfStrEq{\s}{Y}{\IfStrEq{\bg}{AB+}{\stepcounter{ABp}}{}}{\IfStrEq{\d}{N}{\IfStrEq{\tr}{N}{\IfStrEq{\bg}{AB+}{\stepcounter{ABp}}{}}{}}{} }
\IfStrEq{\s}{Y}{\IfStrEq{\bg}{AB-}{\stepcounter{ABm}}{}}{\IfStrEq{\d}{N}{\IfStrEq{\tr}{N}{\IfStrEq{\bg}{AB-}{\stepcounter{ABm}}{}}{}}{} }
}
% set total values
\setcounter{TotalB}{\numexpr\value{FemaleB}+\value{MaleB}\relax}
\setcounter{TotalU}{\numexpr\value{FemaleU}+\value{MaleU}\relax}
% set total values for alive and death members
\setcounter{Total}{\numexpr\value{Female}+\value{Male}\relax}
\setcounter{TotalD}{\numexpr\value{FemaleD}+\value{MaleD}\relax}
% set total values for transfer members
\setcounter{TotalT}{\numexpr\value{FemaleT}+\value{MaleT}\relax}
% set values for existing members
\setcounter{MaleE}{\numexpr\value{Male}-\value{MaleT}-\value{MaleD}\relax}
\setcounter{FemaleE}{\numexpr\value{Female}-\value{FemaleT}-\value{FemaleD}\relax}
\setcounter{TotalE}{\numexpr\value{MaleE}+\value{FemaleE}\relax}
% set values for existing baptised members
\setcounter{TotalBE}{\numexpr\value{FemaleBE}+\value{MaleBE}\relax}
% set values for areawise
\setcounter{AT}{\numexpr\value{A}\relax}
\setcounter{BT}{\numexpr\value{B}\relax}
\setcounter{CT}{\numexpr\value{C}\relax}
\setcounter{DT}{\numexpr\value{D}\relax}
\setcounter{ET}{\numexpr\value{E}\relax}
\setcounter{FT}{\numexpr\value{F}\relax}
\setcounter{AreaT}{\numexpr\value{A}+\value{B}+\value{C}+\value{D}+\value{E}+\value{F}\relax}
\setcounter{TotalG}{\numexpr\value{GA}+\value{GB}+\value{GC}+\value{GD}+\value{GE}+\value{GF}\relax}
\setcounter{TotalGH}{\numexpr\value{GAH}+\value{GBH}+\value{GCH}+\value{GDH}+\value{GEH}+\value{GFH}\relax}
\setcounter{TotalUME}{\numexpr\value{MaleE}-\value{MaleBE}\relax}
\setcounter{TotalUFE}{\numexpr\value{FemaleE}-\value{FemaleBE}\relax}
\setcounter{TotalUE}{\numexpr\value{TotalUME}+\value{TotalUFE}\relax}
% Total for suspension
\setcounter{TotalSus}{\numexpr\value{FSus}+\value{MSus}\relax}
% Total blood group for existing members
\setcounter{BloodT}{\numexpr\value{Ap}+\value{Am}+\value{Bp}+\value{Bm}+\value{Op}+\value{Om}+\value{ABp}+\value{ABm}\relax}
\bigskip
\vspace*{3mm}
\begin{tcolorbox}[colback=blue!80!white, colframe=red!75!black, rounded corners, halign=center]
\color{white}\LARGE\fontsize{185}{185}\bfseries\section*{\MakeUppercase{ABC membership summary}}
\end{tcolorbox}
%\tcbset{enhanced,colback=blue!80!white,colframe=yellow!75!black,fonttitle=\bfseries,frame code app={\path[tcb fill frame]
%([yshift=-2mm]frame.north)circle (8mm); } }
%\begin{tcolorbox}[title=\LARGE \bfseries \hfill ~ABC \hfill~]
%\color{white}\LARGE\bfseries\section*{\MakeUppercase{\hfill membership summary\hfill~}}
%\end{tcolorbox}
\bigskip
\vspace{10mm}
\begin{tcolorbox}[enhanced,arc=3mm,boxrule=1.5mm,frame hidden,colback=blue!10!white,borderline={1mm}{0mm}{blue,dotted} ]
% print results for all members
\hspace*{5mm}\begin{minipage}{5mm}
\begin{tabular}{llr}
Male Membership &: & \theMale \\
Female Membership &: & \theFemale \\
\bottomrule
\it Total & : & \theTotal \\
&&\\
No. of Male Unbaptised & : & \theMaleU \\
No. of Female Unbaptised & : & \theFemaleU\\
\bottomrule
\it Total & : & \theTotalU \\
&& \\
Male Baptised & : & \theMaleB \\
Female Baptised & : & \theFemaleB \\
\bottomrule
\it Total & : & \theTotalB
\end{tabular}
\end{minipage}\hfill
\begin{minipage}{5mm}
\begin{tabular}{llllr}
No. of Male Death & & &: & \theMaleD \\
No. of Female Death & &&: & \theFemaleD\\
\bottomrule
\it Total & && : & \theTotalD \\
&&&&\\
Male Transfers &&& : & \theMaleT\\
Female Transfers &&& : & \theFemaleT\\
\bottomrule
\it Total &&&: & \theTotalT
\end{tabular}
\end{minipage}\hfill
\hspace*{-10mm}\begin{minipage}{5mm}
\begin{tabular}{llcc}
\toprule
{\bf Areawise } & & {\bf Household} & {\bf Members}\\ \midrule
Area 1 & : & \theAH & \theA \\
Area 2 & : & \theBH & \theB \\
Area 3 & : & \theCH & \theC \\
Area 4 & : & \theDH & \theD \\
Area 5 & : & \theEH & \theE \\
Area 6 & : & \theFH & \theF \\
\bottomrule
\it Total & : & \theSerial & \theAreaT
\end{tabular}
\end{minipage}\hfill~
\end{tcolorbox}
\bigskip
%\begin{minipage}{5mm}
%% print results for death members
%\begin{tabular}{llllr}
%No. of Male Death & & &\hspace{1mm}: & \theMaleD \\
%No. of Female Death & &&\hspace{1mm}: & \theFemaleD\\
%\bottomrule
%\it Total & &&\hspace{-0.07mm} : & \theTotalD
%\end{tabular}
%\end{minipage}\hfill\hfill
%\begin{minipage}{5mm}
%% print results for unbaptised member
%\end{minipage}\hfill\hfill
%\begin{minipage}{5mm}
%\begin{tabular}{llr}
%Male Transfers & : & \theMaleT\\
%Female Transfers & : & \theFemaleT\\
%\bottomrule
%\it Total &: & \theTotalT
%\end{tabular}
%\end{minipage}\hfill\hfill~
\bigskip
\begin{tcolorbox}[enhanced,arc=3mm,boxrule=1.5mm,frame hidden,colback=green!10!white,borderline={1mm}{0mm}{green,dotted} ]
\bigskip
%\begin{mybox}[\hfill Existing Members \hfill]{}
\hspace*{5mm}\begin{minipage}{5mm}
\begin{tabular}{llr}
Existing Male & : & \theMaleE\\
Existing Female & : & \theFemaleE\\
\bottomrule
\it Total &: & \theTotalE \\
&&\\
Existing Baptised Male & : & \theMaleBE\\
Existing Baptised Female & : & \theFemaleBE\\
\bottomrule
\it Total & : & \theTotalBE\\
&&\\
Unbaptised Existing Male & : & \theTotalUME \\
Unbaptised Existing Female & : & \theTotalUFE\\
\bottomrule
\it Total & :& \theTotalUE
\end{tabular}
\end{minipage}\hfill
\begin{minipage}{5mm}
\begin{tabular}{lcc}
\toprule
{\bf Blood Group} & &{\bf Members}\\ \midrule
\hspace*{9mm} A+ & : & \theAp \\
\hspace*{9mm} A~- & : & \theAm \\
\hspace*{9mm} B+ & : & \theBp \\
\hspace*{9mm} B~- & : & \theBm \\
\hspace*{9mm} O+ & : & \theOp \\
\hspace*{9mm} O~- & : & \theOm \\
\hspace*{7mm} AB+ & : & \theABp \\
\hspace*{7mm} AB~- & : & \theABm \\
\bottomrule
\it \hfill~~~ Total \hfill~ & : & \theBloodT
\end{tabular}
\end{minipage}\hfill
\hspace*{-10mm}\begin{minipage}{5mm}
\begin{tabular}{llcc}
\toprule
{\bf Areawise } & & {\bf Household} & {\bf Members}\\ \midrule
Area 1 & : & \theGAH & \theGA \\
Area 2 & : & \theGBH & \theGB \\
Area 3 & : & \theGCH & \theGC \\
Area 4 & : & \theGDH & \theGD \\
Area 5 & : & \theGEH & \theGE \\
Area 6 & : & \theGFH & \theGF \\
\bottomrule
\it Total & : & \theTotalGH & \theTotalG \\
&&&\\
Female Suspension&:& &\theFSus \\
Male Suspension&:& &\theMSus \\
\bottomrule
\it Total &:& &\theTotalSus \\
\end{tabular}
\end{minipage}\hfill~
\end{tcolorbox}
\end{document}
答案1
正如发布的那样(在一台 3 年前的笔记本电脑上),我通常得到
real 0m7.695s
user 0m5.013s
sys 0m2.650s
如果我将其增加到 800 行以上,则需要
real 24m42.629s
user 24m38.998s
sys 0m2.636s
DTLloaddb
虽然和的编码风格\IfStrEq
显然效率低下且不适用于大型集合,但按照现代标准这还是相当慢的。
这不是 TeX 速度的内在问题,例如每次构建 lualatex 或 xelatex 格式时,都会读取文件 UnicodeData.txt 以获取大小写映射和其他信息,这些信息超过 29,000 行,每行有 15 个;
分隔的字段,只需一秒钟左右即可用 tex 进行解析并分配相关内容\lccodes
等。
看来您使用的循环(至少)是二次的,因此如果您将输入时间延长 10 倍,则运行时间会延长 100 倍。由于您似乎只对某些字段进行总计,因此应该可以使其时间与输入的大小成线性关系。
相比之下,下面的文件只需不到 2 秒
real 0m1.780s
user 0m1.250s
sys 0m0.515s
要处理您展示的格式的 800 行文件
$ wc -l MemberSummary.csv
800 MemberSummary.csv
制作 22 页如下内容
\documentclass[landscape]{article}
\usepackage{graphicx}
\usepackage{longtable}
\def\gloop#1\repeat{\gdef\iterate{#1\relax\expandafter\iterate\fi}%
\iterate \let\iterate\relax}
\newread\zz
\openin\zz=MemberSummary.csv
\begin{document}
{\catcode`\,=\catcode`\& % make comma a table separator
\read\zz to \hdline
\footnotesize
\setlength\tabcolsep{1pt}
\setlength\LTleft{-5cm}
\setlength\LTright{-5cm plus 1fil}
\begin{longtable}{lllllllllllllllllllllll}
% \hdline
\endhead
\gloop
\ifeof\zz\else
\read\zz to \tmp\tmp\\
\repeat
\end{longtable}
}
\end{document}