Take the 2-minute tour ×
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 have a data.txt file and it contains an array of numbers, I included it in the preamble of the .tex file, now I would like to display some specific entry from the data file, not the whole data set but just some of them, how should I do?

share|improve this question
1  
There is no way to do this exactly as you describe, but there are various ways to deal with data of this sort. See Using external tables in TikZ or File input and output or Formatting complex table from CSV using datatool for some examples. –  Alan Munn Nov 15 '11 at 3:05
add comment

1 Answer

up vote 6 down vote accepted

You can use the PGFplotstable package, which is part of PGFplots, for this.

The data would be loaded into a table macro using \pgfplotstableread{data.txt}\datatable (there are various options for accommodating different data file variants), after which you can access an individual element using \pgfplotstablegetelem{<row>}{<column>}\of\datatable. The element will then be available as \pgfplotsretval.

share|improve this answer
    
Thanks a lot. Works like a charm. –  Shuhao Cao Nov 16 '11 at 1:51
add comment

Your Answer

 
discard

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.