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 have CSV files of different lengths. For example

0,0, 5, 5, 1
0,5, 5, 11, 2
0,11, 5, 16, 1
5,0, 10, 6, 1
5,6, 10, 11, 2

I want to get the value of the last element of the c and d columns, for example c=10 and d=11. And every time with a different file of different length. I am using the datatool package.

\eappto\mydraws{[gray, fill=\k,line width=0.05cm] (axis cs:\a,\b) rectangle (axis cs:\c,\d);}%

I don't know how I can access only the last element of a specific column.

share|improve this question
Please use the code formatting options on the edit menu marked with the symbol {} or select your code and hit Ctrl+K or manually indent the code lines with four whitespace characters. – percusse Jan 21 '13 at 16:14
up vote 4 down vote accepted

You could just step thru the DB set a global to the appropriate column entry, and at the end it will contain the last entry:

enter image description here



\usepackage{filecontents}% Comment to prevent overwriting MyData.csv
a, b,  c,  d, e  
0, 0,  5,  5, 1
0, 5,  5, 11, 2 
0,11,  5, 16, 1
5, 0, 10,  6, 1
5, 6, 10, 11, 2





LastC = \LastC, and LastD = \LastD
share|improve this answer

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.