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?
Asked
Active
Viewed 403 times
3
Shuhao Cao
- 3,131
- 3
- 29
- 33
-
1There 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 03:05
1 Answers
7
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.
Jake
- 232,450