3

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?

Shuhao Cao
  • 3,131
  • 3
  • 29
  • 33

1 Answers1

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