Criando rótulos - usando dados de planilhas Excel - selecionando coluna específica

Criando rótulos - usando dados de planilhas Excel - selecionando coluna específica

Tenho que criar recibos de mesa (etiquetas). Para estes dados estão disponíveis em planilha excel. Os nomes das colunas são - RollNo, Assunto, Local do Exame (centro de exames).

Atualmente estamos criando recibos de mesa usando CSVtools. O rótulo parece -

NAME OF EXAMINATION

Subject : xyz

Roll No. : 000000

Para isso, temos que criar várias planilhas de dados csv - local do exame e assunto. Existe uma maneira de, sem criar várias planilhas de dados csv, podermos criar rótulos em termos de local de exame e assunto?

MWE:

\documentclass[a4paper,12pt]{article}

\usepackage{csvtools}
\usepackage[left=.5cm,right=.5cm,top=.5cm,bottom=.5cm]{geometry}
\usepackage{multicol}
\usepackage{xcolor}
\usepackage{filecontents}
\begin{filecontents*}{data.csv}
RollNo,Subject,Venue
022701,Sociology,Deptt. of Physics
022702,Sociology,Deptt. of Physics
022704,Sociology,Deptt. of Physics
022705,Sociology,Deptt. of Physics
022706,Sociology,Deptt. of Physics
022707,Sociology,Deptt. of Physics
022708,Sociology,Deptt. of Physics
022709,Sociology,Deptt. of Physics
022709,Sociology,Deptt. of Physics
022710,Sociology,Deptt. of Physics
023001,Psychology,Deptt. of Physics
023002,Psychology,Deptt. of Physics
023004,Psychology,Deptt. of Physics
023005,Psychology,Deptt. of Physics
023006,Psychology,Deptt. of Physics
023007,Psychology,Deptt. of Physics
023008,Psychology,Deptt. of Physics
023009,Psychology,Deptt. of Physics
023010,Psychology,Deptt. of Physics
\end{filecontents*}

\begin{document}

\applyCSVfile{data.csv}{% here put the name of the file
%\begin{multicols}{2}
\noindent\fbox{\parbox{6.3cm}{%
{\color{white}.}\\[7pt]
\centering{\LARGE UGC NET - 2014}\\[2pt]
\raggedright
{\Large Subject : \insertSubject}\\[5pt]
{\Large Roll No. : \textbf{0\insertRollNo}}\\[12pt]
}} % This is for parbox
%\end{multicols}
}% This is for CSV file


\end{document}

Responder1

Aqui está um código que deve servir como ponto de partida. Isso usa datatoolpacote. Eu adicionei uma coluna com uma chave curta centeralém de suas colunas.

center,RollNo,Subject,Venue
Bangalore,022701,Sociology,Deptt. of Physics
Bangalore,022702,Sociology,Deptt. of Physics
Bangalore,022704,Sociology,Deptt. of Physics
Bangalore,022705,Sociology,Deptt. of Physics

Na quarta coluna, você pode especificar o centro completo, se desejar.

\documentclass[a4paper,12pt]{article}
\usepackage[left=.5cm,right=.5cm,top=.5cm,bottom=.5cm]{geometry}
\usepackage{xcolor}
\usepackage{filecontents}
\begin{filecontents*}{data.csv}
center,RollNo,Subject,Venue
Bangalore,022701,Sociology,Deptt. of Physics
Bangalore,022702,Sociology,Deptt. of Physics
Bangalore,022704,Sociology,Deptt. of Physics
Bangalore,022705,Sociology,Deptt. of Physics
Bangalore,022706,Sociology,Deptt. of Physics
Bangalore,022707,Sociology,Deptt. of Physics
Bangalore,022708,Sociology,Deptt. of Physics
Bangalore,022709,Sociology,Deptt. of Physics
Bangalore,022709,Sociology,Deptt. of Physics
Bangalore,022710,Sociology,Deptt. of Physics
Mangalore,023001,Psychology,Deptt. of Physics
Mangalore,023002,Psychology,Deptt. of Physics
Mangalore,023004,Psychology,Deptt. of Physics
Mangalore,023005,Psychology,Deptt. of Physics
Mangalore,023006,Psychology,Deptt. of Physics
Mangalore,023007,Psychology,Deptt. of Physics
Mangalore,023008,Psychology,Deptt. of Physics
Mangalore,023009,Psychology,Deptt. of Physics
Mangalore,023010,Psychology,Deptt. of Physics
\end{filecontents*}

\usepackage{datatool}
\DTLloaddb{data}{data.csv}

\begin{document}
This is for Bangalore center

\DTLforeach*[\DTLisopenbetween{\center}{B}{C}]{data}{%
 \center=center,\roll=RollNo,\sub=Subject, \venue=Venue}{%
   \noindent\fbox{\parbox{6.3cm}{%
{\color{white}.}\\[7pt]
\centering{\LARGE UGC NET - 2014}\\[2pt]
\raggedright
{\Large Subject : \sub}\\[5pt]
{\Large Roll No. : \textbf{\roll}}\\[12pt]
}}\hfill % This is for parbox
}%

\clearpage
This is for Mangalore

\DTLforeach*[\DTLisopenbetween{\center}{M}{N}]{data}{%
 \center=center,\roll=RollNo,\sub=Subject, \venue=Venue}{%
   \noindent\fbox{\parbox{6.3cm}{%
{\color{white}.}\\[7pt]
\centering{\LARGE UGC NET - 2014}\\[2pt]
\raggedright
{\Large Subject : \sub}\\[5pt]
{\Large Roll No. : \textbf{\roll}}\\[12pt]
}}\hfill % This is for parbox
}%

\clearpage
This is for Sociology

\DTLforeach*[\DTLisopenbetween{\sub}{S}{T}]{data}{%
 \center=center,\roll=RollNo,\sub=Subject, \venue=Venue}{%
   \noindent\fbox{\parbox{6.3cm}{%
{\color{white}.}\\[7pt]
\centering{\LARGE UGC NET - 2014}\\[2pt]
\raggedright
{\Large Subject : \sub}\\[5pt]
{\Large Roll No. : \textbf{\roll}}\\[12pt]
}}\hfill % This is for parbox
}%

\clearpage
This is for  Psychology

\DTLforeach*[\DTLisopenbetween{\sub}{P}{Q}]{data}{%
 \center=center,\roll=RollNo,\sub=Subject, \venue=Venue}{%
   \noindent\fbox{\parbox{6.3cm}{%
{\color{white}.}\\[7pt]
\centering{\LARGE UGC NET - 2014}\\[2pt]
\raggedright
{\Large Subject : \sub}\\[5pt]
{\Large Roll No. : \textbf{\roll}}\\[12pt]
}}\hfill % This is for parbox
}%

\end{document}

insira a descrição da imagem aqui

Observe que para arquivos CSV grandes, isso pode ser compilado lentamente. Isso pode ser curado até certo ponto usando pgfplotstable. Aqui, um arquivo de dados grande e único pode ser filtrado para um centro ou assunto específico e arquivos csv individuais podem ser criados instantaneamente. Depois de criados, você pode criar os rótulos usando seu csvtoolspacote ou usando datatool. Aqui está o código de exemplo que usa o mesmo data.csvdo código anterior.

\documentclass[a4paper,12pt]{article}
\usepackage[left=.5cm,right=.5cm,top=.5cm,bottom=.5cm]{geometry}
\usepackage{xcolor}

\usepackage{pgfplotstable,xstring}
\pgfplotsset{compat=1.11}

\usepackage{datatool}

\pgfplotstableread[col sep=comma]{data.csv}\data
\begin{document}
%%----------------------------------------------------------subjectwise
%% following will filter all Psychology rows and save it as Psychology.csv
\pgfplotstablesave[col sep=comma,
    row predicate/.code={%
    \pgfplotstablegetelem{#1}{Subject}\of\data%
    \IfStrEq{\pgfplotsretval}{Psychology}{%True            %% >>imp<< Psychology is case sensitive, psychology won't work
    \relax}%
    {\pgfplotstableuserowfalse}%False
  }%
]
{\data}
{Psychology.csv}
%%----------------------------------------------------------
%% from here use datatool
\DTLloaddb{Psychology}{Psychology.csv}
\DTLforeach{Psychology}{%
 \center=center,\roll=RollNo,\sub=Subject, \venue=Venue}{%
   \noindent\fbox{\parbox{6.3cm}{%
{\color{white}.}\\[7pt]
\centering{\LARGE UGC NET - 2014}\\[2pt]
\raggedright
{\Large Subject : \sub}\\[5pt]
{\Large Roll No. : \textbf{\roll}}\\[12pt]
}}\hfill % This is for parbox
}%

\clearpage
%%---------------------------------------------------------- centerwise
%% following will filter all Bangalore rows and save it as bangalore.csv
\pgfplotstablesave[col sep=comma,
    row predicate/.code={%
    \pgfplotstablegetelem{#1}{center}\of\data%
    \IfStrEq{\pgfplotsretval}{Bangalore}{%True                       %% >>imp<< Bangalore is case sensitive
    \relax}%
    {\pgfplotstableuserowfalse}%False
  }%
]
{\data}
{bangalore.csv}
%%----------------------------------------------------------
%% from here use datatool/csvtools
\DTLloaddb{bangalore}{bangalore.csv}
\DTLforeach{bangalore}{%
 \center=center,\roll=RollNo,\sub=Subject, \venue=Venue}{%
   \noindent\fbox{\parbox{6.3cm}{%
{\color{white}.}\\[7pt]
\centering{\LARGE UGC NET - 2014}\\[2pt]
\raggedright
{\Large Subject : \sub}\\[5pt]
{\Large Roll No. : \textbf{\roll}}\\[12pt]
}}\hfill % This is for parbox
}%
\end{document}

informação relacionada