# Dynamically color table elements while using an input file

I like to create a table from file (example) and also dynamically color individual elements (example). I'm not tied to pgfsplottable and not even share some combination with macros can produced the desired effect.

In the MWE below (thanks!), I like to have the functionality of having any cell greater than 0.8 colored green. I don't want to hardcode the table because the input file may change.

\documentclass{scrreprt}
\usepackage{pgfplotstable,booktabs}
% I did it to create your file
\usepackage{filecontents} % <-- To create files on the fly

\begin{filecontents*}{avg_value.csv}
,M23,F231,M36,F44,F63,M70
M23,1.00,0.81,0.88,0.83,0.41,0.82
F231,,1.00,0.52,0.56,0.25,0.94
M36,,,1.00,0.62,0.94,0.96
F44,,,,1.00,0.43,0.23
F63,,,,,1.00,0.22
M70,,,,,,1.00
\end{filecontents*}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\pgfplotstabletypeset[
col sep = comma,
string replace*={_}{\textsubscript},
every last row/.style={after row=\bottomrule},
display columns/0/.style={string type,column name={}}
]
{avg_value.csv}

\end{document}


This is a good chance to practice 's assign cell content

\documentclass{scrreprt}
\usepackage[table]{xcolor}
\usepackage{pgfplotstable,booktabs}
% I did it to create your file
\usepackage{filecontents} % <-- To create files on the fly

\begin{filecontents*}{avg_value.csv}
,M23,F231,M36,F44,F63,M70
M23,1.00,0.81,0.88,0.83,0.41,0.82
F231,,1.00,0.52,0.56,0.25,0.94
M36,,,1.00,0.62,0.94,0.96
F44,,,,1.00,0.43,0.23
F63,,,,,1.00,0.22
M70,,,,,,1.00
\end{filecontents*}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\pgfplotstabletypeset[
col sep = comma,
string replace*={_}{\textsubscript},
every last row/.style={after row=\bottomrule},
display columns/0/.style={string type,column name={}},
assign cell content/.code={
\edef\tempcellcontent{#1}
\ifx\tempcellcontent\empty
\pgfkeyslet{/pgfplots/table/@cell content}{\tempcellcontent}
%\message{^^J^^J#1}
\else
\ifdim#1pt>0.8pt
\pgfmathparse{#1*400-300}
\edef\tempcellcontent{\noexpand\cellcolor{green!\pgfmathresult!}#1}
\pgfkeyslet{/pgfplots/table/@cell content}{\tempcellcontent}
\else
\edef\tempcellcontent{#1}
\pgfkeyslet{/pgfplots/table/@cell content}{\tempcellcontent}
%   \pgfkeyssetvalue{/pgfplots/table/@cell content}{#1}
\fi
\fi
},
]
{avg_value.csv}

\end{document}