I faced a very similar problem to pgfplotsinvokeforeach using parameter when you have the hash symbol as e.g. comment chars. Python uses this character for comments so I want to either use it in my column definition or to comment it out.
I want to give you an idea what I do with Python:
import numpy as np
np.savetxt('test.csv',
np.column_stack((np.array([0,1]),
np.array([50, 49.995]),
np.array([0, 0.5726]),
np.array([-32.8125, -32.8043])),
delimiter=',', header='xval,# yval1,# yval2,# yval3')
Keep in mind that Numpy itself adds already a hash symbol at the beginning of the header line. The LaTeX script of interest (MWE) looks the following:
\documentclass{standalone}
\usepackage{filecontents}
\usepackage{pgfplots}
\begin{filecontents}{test.csv}
# xval,# yval1,# yval2,# yval3
0.0000,50.0000,0.0000,-32.8125
1.0000,49.9950,0.5726,-32.8043
\end{filecontents}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot
table[x=1, y=2, col sep=comma, comment chars=#] {test.csv};
table[x={# xval}, y={# yval2}, col sep=comma] {test.csv};
\end{axis}
\end{tikzpicture}
\end{document}
None of these two examples seems to work probably because this hash symbol is one of the reserved symbols in LaTeX. Escaping or doubling the hash does not help neither. Any help is appreciated.
x indexetc. Thank you! – strpeter Jun 01 '18 at 16:47x={# xval}or evenx={# x_val}(or with escaping these characters) since these characters are forbidden in variables? – strpeter Jun 01 '18 at 23:17comments=''so that this isn't a problem. – Torbjørn T. Jun 02 '18 at 08:07