Tell me more ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to import data from a CSV to a LaTeX file with the datatool package, but I get error messages like:

Undefined control sequence.
Missing } inserted.
Missing } inserted.
Missing \cr inserted.
Missing { inserted.
Misplaced \crcr.
Extra }, or forgotten \endgroup.
Missing } inserted.
Missing } inserted.

Please what is the problem with this code?

%
% texlive-lang-arabic (for fmultico.sty)
% ttf-arabeyes (for arabic fonts)

\documentclass[a4paper]{article}
\usepackage[a4paper,left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage{pdflscape,setspace,amsmath,amssymb}
\usepackage{bidi}
\usepackage{longtable}
%\usepackage{fmultico}
\usepackage{etex}
%\usepackage[postcorrect,noshuffle,insidebox]{automultiplechoice}
\usepackage{amsmath}\usepackage{xltxtra}\usepackage{arabxetex}
\usepackage{datatool}
\DTLloaddb{names}{ph1.csv}
%\usepackage{calligra}
\usepackage{tgschola}
\usepackage{fourier-orns}
\usepackage{graphicx}
\usepackage{wallpaper}
\newfontfamily{\arabicfont}[Script=Arabic,Scale=1]{Rasheeq}
\usepackage[normalem]{ulem}
\usepackage{charter}
\usepackage{microtype}
\hyphenpenalty 100000

\def\signature#1#2{\parbox[b]{1in}{\smash{#1}\vskip12pt}
\hfill \parbox[t]{3cm}{\shortstack{\vrule width 3cm height 0.4pt\\\small#2}}}
\def\sigskip{\vskip0.4in plus 0.1in}
        \def\beginskip{\vskip0.5875in plus 0.1in}

\begin{document}
\begin{landscape}
\pagestyle{empty}
\TileWallPaper{1\paperwidth}{1\paperheight}{border-2.jpg}
%=============================%import the data from csv
\DTLforeach{names}{\name=الاسم,\dg=الدرجة,\stunum=A:StudentNum,\subj=subject}{
\noindent{\color{black}\Huge\decoone\decofourleft\hfill\decofourright\decoone\\
\rotatebox[origin=rt]{-90}{\decofourleft}\hfill\rotatebox[origin=lt]{90}{\decofourright}}

{\centering
%=============================% start print the data in pdf
%=============================% print the 1st logo 
\noindent
\begin{minipage}[l]{3cm}
 \includegraphics[width=.72\linewidth]{moe}
\end{minipage}
\hfill
%%=============================% print the title
\begin{minipage}[c]{6cm}
{\centering
{\onehalfspacing
    {\LARGE\bfseries{\textarab{المملكة العربية السعودية}}}\\%\initfamily
    {\large\bfseries\textarab{وزارة التربية والتعليم}}\\
    {\textarab{جدة}} -- {\textarab{ادارة التربية والتعليم}}\\
    \vskip0.4em
    {\Large\bfseries\textarab{ثانوية الملك فيصل}}}\\
    \par}
\end{minipage}
\hfill
%=============================% print the 2nd logo
\begin{minipage}[r]{3cm}
\includegraphics[width=.92\linewidth]{crown}
\end{minipage}
\vskip1em
%=========%end the logo
%=====%print the header of the content
    {\huge\bfseries\textarab{ شهادة شكر وتقدير}}\par    {\LARGE\color{black}\decofourleft\quad{\color{black}\decoone}\quad\decofourright}\par
    \vskip2em
%=====%print the content with the student name  
    {\textarab{يسرنا أن نهنئ ابننا الدارس: \name}}\par
    {\large\textarab{ على جده واجتهاده ، وحرصه على الارتقاء بمستواه التعليمي والتربوي حيث كانت نتيجته:}}\par}


%============================%print the table 

\vspace{-0.3cm}
\begin{center}
\begin{arab}    
    \begin{minipage}{0.97\linewidth}
\begin{longtable}{|p{5cm}|p{2cm}|p{2cm}|p{3cm}|}
\hline
النسبة المئوية & الدرجة & المادة & رقم الطالب\\
\hline
\subjec & \dg & \subj & \stunum\\[2ex]
\hline
\end{longtable}   
     \vspace{-0.05cm}
    \end{minipage}
    \end{arab}
\end{center}
%=======================%end the table
%================%start the end of content
\begin{center}
\textarab{متمنين له دوام التوفيق والنجاح،،}
\end{center}
\vspace{0.5cm}
%==================%start the signature

\noindent
%\beginskip
{\singlespacing
\vfil
\begin{minipage}[c]{4cm}\begin{center}
\sigskip \signature{\textarab{رئيس القسم}}{\textarab{د.عبد الله الصبحي \\ مدير المدرسة }}
\end{center}\end{minipage}
\hfill
\begin{minipage}[r]{4cm}\begin{center}
\sigskip \signature{\textarab{مدرس المادة}}{\textarab{د.سعيد الزهراني \\ مدرس المادة }}
\end{center}\end{minipage}}

%==================%end the signature
    \noindent{\color{black}\Huge
    \rotatebox[origin=lb]{-90}{\decofourright}\hfill\rotatebox[origin=rb]{90}{\decofourleft}\\
    \decoone\rotatebox[origin=c]{180}{\decofourright}\hfill\rotatebox[origin=c]{180}\decofourleft\decoone}

\pagebreak
}
\end{landscape}   
\end{document}

image here

share|improve this question
2  
This is much too big a document. You need to trim things down to the smallest document that causes the problem. No one will be able to compile this document as is, since we don't have your images etc. But they are not likely to be the cause of the problem. For starters, you have no \DTLloaddb command. You also don't give a sample CSV file. Having Arabic text just makes things more confusing for non Arabic speakers (most of us here), so it might also be helpful to remove that (at least for your column names from the CSV file.) – Alan Munn Apr 17 '12 at 14:12
\DTLloaddb in the header – silver Apr 17 '12 at 14:31
the image i.imgur.com/AFbV8.png – silver Apr 17 '12 at 14:34
2nd image: i.imgur.com/1o1HB.jpg – silver Apr 17 '12 at 14:35
2  
You're not really addressing the main point of my comment. We don't need the images, so you should remove them etc. By providing links to the images, you are saying to us "Please go to the effort of downloading irrelevant images so that you can compile a large file to help me debug the code which I haven't spent much effort debugging myself." Sorry if that's a bit harsh. You need to trim the document down drastically to show the problem. – Alan Munn Apr 17 '12 at 14:36
show 3 more comments

closed as too localized by Alan Munn, Werner, Stefan Kottwitz Apr 17 '12 at 19:40

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, see the FAQ.

Browse other questions tagged or ask your own question.