I want to insert some information from a csv text file or from a mdb (MS data base) base into a latex document. For example I have a document with math exercises and I would like to insert the first and the second element (i.e. exercise) of the base into \begin{enumerate} \end{enumerate}. How could this achieved in LaTeX?

  • 2
    Have you tried datatool package? – user11232 Feb 20 '12 at 10:15

The etoolbox has \docsvlist and \forcsvlist. The documentation for the \docsvlist gives the following example:

\renewcommand*{\do}[1]{\item #1}
\docsvlist{item1, item2, {item3a, item3b}, item4}

If you wanted to stop the list at 2 items, you could use a counter

        \ifnumless{\arabic{item}}{2}{\item #1}{}
      \docsvlist{item1, item2, {item3a, item3b}, item4}
  • I think \docsvist is a good idea. One more question: Let us suppose we have the \docsvlist{item1, item2, {item3a, item3b,item3c, item3d}, item4} and someone wants to take only the item3b and item3d for use with \do command(see Daniels Shub' answer). How this could be achieved?? – kornaros Feb 20 '12 at 15:37
  • @kornaros This is really a new question, and I think it should be asked as such. I think you will need to provide additional information to get an answer. Specifically, what do you know in advance and what do you expect the user to input. – StrongBad Feb 20 '12 at 16:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.