I am trying to typeset two different tables in a moderately large document. The data for the tables are written as comma-separated values in two different .csv files. I am including the different sections of the document into a main file using \include{section-n}. In each file to be included, I read the the table data with \pgfplotstableread{table-n}{\data-n} and then typeset it as in the MWE.
I am able to typeset the first table without problems, but once it tries to read the second table it fails, entering into an infinite loop. Once I break the process it spits out the following error:
ERROR: Use of \pgfplotstableread@checkspecial@line@@ doesn't match its definition.
--- TeX said --- \pgfplotstable@LINE ->$S igma$,15,,,,1057 l.315 \pgfplotstableread{predevCN2.csv}{\CNPre2} ^^M
--- HELP --- It's probably one of the picture-drawing commands, and you have used the wrong syntax for specifying an argument. If it's \@array that doesn't match its definition, then there is something wrong in an @-expression in the argument of an array or tabular environment---perhaps a fragile command that is not \protect'ed.
Now, what is going on?
Here's my best attempt at a MWE which captures my intentions, yet it fails in a completely different way than my main file. I'm also not sure about why it fails, but it seems to be related.
\documentclass{article}
\usepackage{lipsum}
\usepackage{filecontents}
\usepackage{booktabs}
\usepackage{array}
\usepackage{pgfplots}
\pgfplotsset{compat=1.7}
\usepackage{pgfplotstable}
\pgfplotstableset{
col sep=comma,
every head row/.style={%
before row=\toprule,%
after row=\midrule},%
every last row/.style={%
after row=\bottomrule}%
}
\begin{filecontents}{firstTable.csv}
A,B,C,D,E
1,2,3,4,5
$\Sigma$i,ii,iii,iv,v
\end{filecontents}
\begin{filecontents}{secondTable.csv}
a,b,c,d,e
1,2,3,4,5
I,II,III,IV,V
\end{filecontents}
\begin{filecontents}{section1.tex}
Here's a nice table:
\pgfplotstableread{firstTable.csv}{\loadeddata1}
\begin{table}
\centering
\pgfplotstabletypeset[%
columns={A,B,C,D,E}%
]{\loadeddata1}
\caption{Simple caption for a simpler table.}
\label{tab:table1}
\end{table}
\end{filecontents}
\begin{document}
\section{Here goes section 1}
\lipsum[1]
\include{section1}
\section{Section 2}
And here we put another table.
\pgfplotstableread{secondTable.csv}{\loadeddata2}
\begin{table}
\centering
\pgfplotstabletypeset[%
columns={a,b,c,d,e}%
]{\loadeddata2}
\caption{Fancy caption for a simple table.}
\label{tab:table2}
\end{table}
\end{document}
%%%% Local Variables:
%%%% mode: latex
%%%% TeX-engine: xetex
%%%% End:
columns/myColumnName/.append style = {string replace={1}{$<$~1 month}}, where the1is the value I used in my csv file instead of the messy string I had to begin with. – PatrickT Mar 03 '18 at 13:22