This is a follow-up to this question. I am trying to get points to be graphed using data from an external file. The vertical coordinates are countries, and the horizontal ones are years. For this to work I need to supply the axis environment with the list of countries as symbolic coordinates, and this is where I have problems.
In the MWE below, in the first tikzpicture I supply the list of countries manually, and everything is fine. In the second tikzpicture, I supply the list as loaded from an external file using \CatchFileDef command from the catchfile package. This creates an error even though the command \listcountries seems to hold the exact same text as the one I was putting manually (namely : AUT,GER,FRA).
Can you explain why \CatchFileDef doesn't work in this context?
\documentclass{standalone}
\usepackage{filecontents,catchfile}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.7}
\usepackage{pgfplotstable}
\begin{filecontents}{testcountries.txt}
AUT,GER,FRA
\end{filecontents}
\begin{filecontents}{CountryYears.csv}
#########################################################
country,year
AUT,1998
AUT,1999
AUT,2000
GER,1999
GER,2000
GER,2001
GER,2002
FRA,2000
FRA,2001
FRA,2002
FRA,2003
#########################################################
\end{filecontents}
\begin{document}
\pgfplotstableset{columns/country/.style={string type}}
\pgfplotstableread[col sep=comma]{CountryYears.csv}\loadeddata
\CatchFileDef{\listcountries}{testcountries.txt}{}
This is the list of countries from testcountries.txt: \listcountries
\bigskip
\begin{tikzpicture}
\begin{axis}[symbolic y coords={AUT,GER,FRA
},ytick=data,
x tick label style={/pgf/number format/.cd,%
scaled x ticks = false,
set thousands separator={},
fixed},]
\addplot[only marks] table[x=year,y=country] \loadeddata;
\end{axis}
\end{tikzpicture}
\begin{tikzpicture}
\begin{axis}[symbolic y coords={\listcountries
},ytick=data,
x tick label style={/pgf/number format/.cd,%
scaled x ticks = false,
set thousands separator={},
fixed},]
\addplot[only marks] table[x=year,y=country] \loadeddata;
\end{axis}
\end{tikzpicture}
\end{document}