![요일을 숫자로 변환](https://rvso.com/image/392355/%EC%9A%94%EC%9D%BC%EC%9D%84%20%EC%88%AB%EC%9E%90%EB%A1%9C%20%EB%B3%80%ED%99%98.png)
텍스메이커,
파일 내용의 요일을 표시 번호로 변경하는 방법:
월요일 = 2, 화요일 = 3...토요일 = 7, 일요일 = 1
내 코드
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{file.tex}
%Type =1,2...10
No,Dayofweek,Name
1,Monday,A
2,Tuesday,B
3,Wednesday,D
30,Thursday,C
31,Friday,M
131,Saturday,N
132,Sunday,K
\end{filecontents*}
\usepackage{datatool}
\DTLloaddb[autokeys=false]{file}{file.tex}
\begin{document}
Display Dayofweek => Number
\DTLforeach*
{file}% Database
{\No=No,\Dayofweek=Dayofweek,\Name=Name}{%
\noindent\Dayofweek \quad \Name\par
}%
\end{document}
답변1
질문을 올바르게 이해했다면 ...
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{file.tex}
%Type =1,2...10
No,Dayofweek,Name
1,Monday,A
2,Tuesday,B
3,Wednesday,D
30,Thursday,C
31,Friday,M
131,Saturday,N
132,Sunday,K
\end{filecontents*}
\usepackage{datatool}
\DTLloaddb[autokeys=false]{file}{file.tex}
\newcommand\Sundaycode{1}
\newcommand\Mondaycode{2}
\newcommand\Tuesdaycode{3}
\newcommand\Wednesdaycode{4}
\newcommand\Thursdaycode{5}
\newcommand\Fridaycode{6}
\newcommand\Saturdaycode{7}
\newcommand\daycode[1]{\csname #1code\endcsname}
\begin{document}
Display Dayofweek $=>$ Number
\DTLforeach*
{file}% Database
{\No=No,\Dayofweek=Dayofweek,\Name=Name}{%
\noindent\daycode{\Dayofweek} \quad \Name\par
}%
\end{document}