# Change Column Name and Cell Value Pgfplotstable

I have this csv file:

,Accuracy
1,0.982
2,0.982
3,0.982
4,0.988
5,0.916
6,0.976
7,0.958
8,0.97
9,0.945
10,0.988
11,0.969


This is the screenshot when I imported it into Latex file:

This is the working example file:

\documentclass[a4,12pt]{report}

\usepackage{pgfplotstable}

\begin{document}

\begin{table}[h!]
\caption{Accuracy value}
\label{tab:cvinitial}
\begin{center}
\pgfplotstabletypeset[
col sep=comma,
string type,
display columns/ /.style={column type={|l|},}
display columns/Accuracy/.style={column type={|l|}},
every nth row={1}{before row=\hline},
every last row/.style={after row=\hline},
]{
,Accuracy
1,0.982
2,0.982
3,0.982
4,0.988
5,0.916
6,0.976
7,0.958
8,0.97
9,0.945
10,0.988
11,0.969
}
\end{center}
\end{table}

\end{document}


I have several questions:

1. How can I change the first column name from 0 to another value/text, for example No?
2. How can I change the last element of the first column name (11) to another value/text, for example Average?
3. How do I add vertical line between columns?

Thank you in advance for the help.

1. To change the predefined value of this empty cell 0 to No, I added played with assign column name. (I am not claiming it is necessarily the most elegant way.)

2. To add a vertical bar, I played with every even column and every odd column.

3. To replace the element of the table, I added every row 10 column 0/.style={postproc cell content/.style={@cell content=Average}},

\documentclass[a4,12pt]{report}

\usepackage{pgfplotstable}
%\pgfplotsset{compat=1.15}
\begin{document}

\begin{table}[h!]
\caption{Accuracy value}
\label{tab:cvinitial}
\begin{center}
\pgfplotstabletypeset[
col sep=comma,
assign column name/.style={
/pgfplots/table/column name={\ifx#10
No
\else
#1
\fi}
},
string type,
%display columns/ /.style={column type={|l|},}
every odd column/.style={
},
every even column/.style={
},
every row 10 column 0/.style={postproc cell content/.style={@cell
content=Average}},
every nth row={1}{before row=\hline},
every last row/.style={after row=\hline},
]{
,Accuracy
1,0.982
2,0.982
3,0.982
4,0.988
5,0.916
6,0.976
7,0.958
8,0.97
9,0.945
10,0.988
11,0.969
}
\end{center}
\end{table}

\end{document}


• I got this error Package pgfplots Error: Sorry, 'compat=1.16' is unknown in this context. Please use at most 'compat=1.15'. \pgfplotsset{compat=1.16} @marmot – Akhmad Zaki Jan 28 at 22:46
• @AkhmadZaki This just means you do not run the most recent version of pgfplotstable. The above code works fine with \pgfplotsset{compat=1.15} or without \pgfplotsset{compat=...}. – user121799 Jan 28 at 22:55
• yes, it works, but how about changing the value 11 in the first column and adding vertical line between columns @marmot ? – Akhmad Zaki Jan 28 at 22:57
• @AkhmadZaki I added these things. – user121799 Jan 28 at 23:14
• The vertical line at the left and the right side of the table still not showing. How to add it ? – Akhmad Zaki Jan 29 at 2:45