# Normalize by the i-th value of a series

I have a data.csv that looks like (note that there's no header)  0.0, 0.8, 0.5 0.5, 0.4, 0.7 1.0, 1.0, 0.4  that I want to plot using pgfplots. I want the plot to rescale the values in the 2nd (index = 1) and 3rd (index = 2) columns by the value in the first row, so that the values become  0.0, 1.0, 1.0 0.5, 0.5, 1.4 1.0, 1.25, 0.8  on the plot. Currently, the way I do this is setting y expr = \thisrowno{1}/0.8 when plotting the 2nd column on the y axis. However, the csv file changes often and having to hard-code this is costly. I also don't have control over the csv generation, so rescaling at data-generation is not feasible. I could easily process this in some other language prior to plotting, but I'm interested to know whether this can be done within pgfplots, and potentially using an arbitrary row (1st and last are obviously the most valuable)

MWE:

\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{filecontents}

\begin{filecontents}{data.csv}
0.0, 0.8, 0.5
0.5, 0.4, 0.7
1.0, 1.0, 0.4
\end{filecontents}

\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}
x index = {0}, y index = {1},
y expr  = \thisrowno{1}/0.8,
col sep = comma,
] {data.csv};
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}


You could just read the values in advance and then use them. This code is based on this answer, that answer. These answers have also been used here, I think.

\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{filecontents}

\begin{filecontents}{data.csv}
0.0, 0.8, 0.5
0.5, 0.4, 0.7
1.0, 1.0, 0.4
\end{filecontents}
\pgfplotstablegetelem{#2}{[index]#3}\of{#1}%
\let#4\pgfplotsretval
}
\newcommand{\NormalizationFromLastRow}[2]{
\pgfplotstablegetrowsof{\datatable}
\pgfmathtruncatemacro{\rownumber}{\pgfplotsretval-1}
\begin{document}
\Normalization{1}{\mynorm}
\NormalizationFromLastRow{1}{\mylastnorm}
\typeout{\mylastnorm}
\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}