TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am certain this is patently obvious, but the solution is eluding me...

Given a dataset stored in CSV:

ID,    col1,  col2, col3
KEY-1, foo    bar,  baz
KEY-2, alice, bob,  chuck

I would like to define a macro \getCol3{KEY-2} that returns chuck. I am getting tripped up by what appears to be internal key structures (and the fact that I just started using datatool).


is what I assumed was in the right direction, but I cannot construct valid values for \therow and \thevalue.

share|improve this question

You need to use \DTLgetvalueforkey

ID,    col1,  col2, col3
KEY-1, foo,   bar,  baz
KEY-2, alice, bob,  chuck

Here, we are using ID as the reference key to find the appropriate row, which is found using the argument #2.

share|improve this answer
of course, i was missing \newcommand*{\thevalue}{} ... i knew is was something simple. thanks! – equalspeterd Jan 12 '12 at 22:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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