# How to display every 4th row in a large data file using pgfplotstable?

Question: I am trying to select certain rows, similar to this question Selecting rows to be displayed with pgfplotstable, however I am not sure how I would go about doing it. I want to display only every 4th row. Something like skip rows between index but more automated than that (the file is fairly long). I have attempted to use the code below code, but I am at a loss as to how I would output only every 4th row (starting from 1 (ie: 1, 5, 9, etc). I assume some type of math operator would work, but how?

\documentclass{standalone}
\usepackage{pgfplotstable}
\begin{document}
obs      number
1         2
2         5
3         3
4         2
5         4
6         1
7         2
8         5
9         3
10        2
11        4
12        1
\pgfplotstabletypeset[
row predicate/.code={%
\ifnum\pgfplotsretval=??\relax %Use some seq operator?
\else\pgfplotstableuserowfalse
\fi}
\end{document}

-

You can use the regular Mod operation for this.

\documentclass{standalone}
\usepackage{pgfplotstable}
\begin{document}
obs      number
1         2
2         5
3         3
4         2
5         4
6         1
7         2
8         5
9         3
10        2
11        4
12        1
\pgfplotstabletypeset[
row predicate/.code={%
\pgfmathparse{int(Mod(\pgfplotsretval,4)}
\ifnum\pgfmathresult=0\relax
\else\pgfplotstableuserowfalse
\fi}

Oops, make it \pgfmathresult=1. –  percusse Nov 2 '12 at 17:06
Note that the use of \pgfplotstablegetelem might be very inefficient, especially for "large tables" (unless "large" means <50 rows). But since obs is more-or-less equivalent to \pgfplotstablerow, you may want to prefer \pgfplotstablerow –  Christian Feuersänger Nov 10 '12 at 21:36