라벨 생성 - Excel 시트의 데이터 사용 - 특정 열 선택

라벨 생성 - Excel 시트의 데이터 사용 - 특정 열 선택

책상 전표(라벨)를 만들어야 합니다. 이 데이터는 Excel 시트에서 사용할 수 있습니다. 열 이름은 RollNo, Subject, Venue of Exam(시험 센터)입니다.

현재 우리는 를 사용하여 책상 전표를 만들고 있습니다 CSVtools. 라벨은 다음과 같습니다 -

NAME OF EXAMINATION

Subject : xyz

Roll No. : 000000

이를 위해 우리는 시험 장소 및 주제별 여러 csv 데이터 시트를 만들어야 합니다. 여러 개의 CSV 데이터 시트를 만들지 않고도 시험 장소와 주제별로 라벨 시험장을 만들 수 있는 방법이 있습니까?

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}

답변1

다음은 시작점 역할을 하는 몇 가지 코드입니다. 이것은 datatool패키지를 사용합니다. center귀하의 열 외에 단축 키가 있는 열을 추가했습니다 .

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

네 번째 열에서는 원하는 경우 전체 중심을 지정할 수 있습니다.

\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}

여기에 이미지 설명을 입력하세요

대용량 csv 파일의 경우 컴파일 속도가 느려질 수 있습니다. 이를 이용하면 어느 정도 치료가 가능합니다 pgfplotstable. 여기에서는 특정 센터나 주제에 대해 대규모 단일 데이터 파일을 필터링할 수 있으며 개별 csv 파일을 즉시 생성할 수 있습니다. 일단 생성되면 csvtools패키지 방식을 사용하거나 를 사용하여 라벨을 생성할 수 있습니다 datatool. 다음은 data.csv이전 코드와 동일한 내용을 사용하는 샘플 코드입니다 .

\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}

관련 정보